From 70935f09526ba9f1d0b2f6af10e18712df73eda9 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 25 Oct 2016 09:54:37 +0200 Subject: [PATCH] Drop support for offscreen GdkWindows These complicate a lot of GdkWindow internals to implement features that not a lot of apps use, and will be better achieved using gsk. So, we just drop it all. --- demos/gtk-demo/Makefile.am | 2 - demos/gtk-demo/demo.gresource.xml | 2 - demos/gtk-demo/offscreen_window.c | 586 ------------------- demos/gtk-demo/offscreen_window2.c | 503 ---------------- docs/reference/gdk/gdk4-sections.txt | 6 - docs/reference/gtk/gtk-docs.sgml | 1 - docs/reference/gtk/gtk4-sections.txt | 20 - gdk/Makefile.am | 1 - gdk/broadway/gdkdisplay-broadway.h | 3 - gdk/broadway/gdkwindow-broadway.c | 6 +- gdk/gdkdevice.c | 12 - gdk/gdkinternals.h | 13 - gdk/gdkoffscreenwindow.c | 764 ------------------------- gdk/gdkwindow.c | 523 ++--------------- gdk/gdkwindow.h | 39 -- gdk/gdkwindowimpl.c | 2 +- gdk/makefile.msc | 1 - gdk/mir/gdkmirwindowimpl.c | 4 +- gdk/quartz/gdkdevice-core-quartz.c | 4 +- gdk/quartz/gdkevents-quartz.c | 7 +- gdk/quartz/gdkscreen-quartz.c | 6 +- gdk/quartz/gdkwindow-quartz.c | 7 +- gdk/wayland/gdkdevice-wayland.c | 12 - gdk/wayland/gdkwindow-wayland.c | 14 +- gdk/win32/gdkdnd-win32.c | 3 - gdk/win32/gdkwindow-win32.c | 3 +- gdk/x11/gdkdisplay-x11.h | 3 - gdk/x11/gdkdnd-x11.c | 3 - gdk/x11/gdkwindow-x11.c | 3 - gtk/Makefile.am | 2 - gtk/gtk-autocleanups.h | 1 - gtk/gtk.h | 1 - gtk/gtkdnd-quartz.c | 4 +- gtk/gtkflowbox.c | 2 +- gtk/gtkgesture.c | 6 +- gtk/gtklistbox.c | 2 +- gtk/gtkoffscreenwindow.c | 308 ---------- gtk/gtkoffscreenwindow.h | 74 --- gtk/gtkscrolledwindow.c | 2 +- gtk/gtktooltip.c | 2 +- gtk/gtkwidget.c | 12 +- gtk/gtkwindow.c | 1 - gtk/makefile.msc.in | 2 - tests/Makefile.am | 12 - tests/gtkoffscreenbox.c | 683 ---------------------- tests/gtkoffscreenbox.h | 52 -- tests/makefile.msc | 6 +- tests/testoffscreen.c | 377 ------------ tests/testoffscreenwindow.c | 87 --- testsuite/gtk/notify.c | 4 - testsuite/gtk/treeview.c | 2 +- testsuite/reftests/label-sizing.ref.ui | 2 +- testsuite/reftests/label-sizing.ui | 2 +- 53 files changed, 79 insertions(+), 4120 deletions(-) delete mode 100644 demos/gtk-demo/offscreen_window.c delete mode 100644 demos/gtk-demo/offscreen_window2.c delete mode 100644 gdk/gdkoffscreenwindow.c delete mode 100644 gtk/gtkoffscreenwindow.c delete mode 100644 gtk/gtkoffscreenwindow.h delete mode 100644 tests/gtkoffscreenbox.c delete mode 100644 tests/gtkoffscreenbox.h delete mode 100644 tests/testoffscreen.c delete mode 100644 tests/testoffscreenwindow.c diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am index f470fc8172..b873418b2b 100644 --- a/demos/gtk-demo/Makefile.am +++ b/demos/gtk-demo/Makefile.am @@ -43,8 +43,6 @@ demos_base = \ markup.c \ menus.c \ modelbutton.c \ - offscreen_window.c \ - offscreen_window2.c \ overlay.c \ overlay2.c \ panes.c \ diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml index f0c7201f3c..3bd3d9f968 100644 --- a/demos/gtk-demo/demo.gresource.xml +++ b/demos/gtk-demo/demo.gresource.xml @@ -167,8 +167,6 @@ markup.c menus.c modelbutton.c - offscreen_window.c - offscreen_window2.c overlay.c overlay2.c pagesetup.c diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c deleted file mode 100644 index 1affe04d1b..0000000000 --- a/demos/gtk-demo/offscreen_window.c +++ /dev/null @@ -1,586 +0,0 @@ -/* Offscreen Windows/Rotated Button - * - * Offscreen windows can be used to transform parts of a widget - * hierarchy. Note that the rotated button is fully functional. - */ -#include -#include - -#define GTK_TYPE_ROTATED_BIN (gtk_rotated_bin_get_type ()) -#define GTK_ROTATED_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ROTATED_BIN, GtkRotatedBin)) -#define GTK_ROTATED_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ROTATED_BIN, GtkRotatedBinClass)) -#define GTK_IS_ROTATED_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ROTATED_BIN)) -#define GTK_IS_ROTATED_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ROTATED_BIN)) -#define GTK_ROTATED_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ROTATED_BIN, GtkRotatedBinClass)) - -typedef struct _GtkRotatedBin GtkRotatedBin; -typedef struct _GtkRotatedBinClass GtkRotatedBinClass; - -struct _GtkRotatedBin -{ - GtkContainer container; - - GtkWidget *child; - GdkWindow *offscreen_window; - gdouble angle; -}; - -struct _GtkRotatedBinClass -{ - GtkContainerClass parent_class; -}; - -GType gtk_rotated_bin_get_type (void) G_GNUC_CONST; -GtkWidget* gtk_rotated_bin_new (void); -void gtk_rotated_bin_set_angle (GtkRotatedBin *bin, - gdouble angle); - -/*** implementation ***/ - -static void gtk_rotated_bin_realize (GtkWidget *widget); -static void gtk_rotated_bin_unrealize (GtkWidget *widget); -static void gtk_rotated_bin_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline); -static void gtk_rotated_bin_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean gtk_rotated_bin_damage (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_rotated_bin_draw (GtkWidget *widget, - cairo_t *cr); - -static void gtk_rotated_bin_add (GtkContainer *container, - GtkWidget *child); -static void gtk_rotated_bin_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_rotated_bin_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gtk_rotated_bin_child_type (GtkContainer *container); - -G_DEFINE_TYPE (GtkRotatedBin, gtk_rotated_bin, GTK_TYPE_CONTAINER); - -static void -to_child (GtkRotatedBin *bin, - double widget_x, - double widget_y, - double *x_out, - double *y_out) -{ - GtkAllocation child_area; - double x, y, xr, yr; - double c, s; - double w, h; - - s = sin (bin->angle); - c = cos (bin->angle); - gtk_widget_get_allocation (bin->child, &child_area); - - w = c * child_area.width + s * child_area.height; - h = s * child_area.width + c * child_area.height; - - x = widget_x; - y = widget_y; - - x -= (w - child_area.width) / 2; - y -= (h - child_area.height) / 2; - - x -= child_area.width / 2; - y -= child_area.height / 2; - - xr = x * c + y * s; - yr = y * c - x * s; - x = xr; - y = yr; - - x += child_area.width / 2; - y += child_area.height / 2; - - *x_out = x; - *y_out = y; -} - -static void -to_parent (GtkRotatedBin *bin, - double offscreen_x, - double offscreen_y, - double *x_out, - double *y_out) -{ - GtkAllocation child_area; - double x, y, xr, yr; - double c, s; - double w, h; - - s = sin (bin->angle); - c = cos (bin->angle); - gtk_widget_get_allocation (bin->child, &child_area); - - w = c * child_area.width + s * child_area.height; - h = s * child_area.width + c * child_area.height; - - x = offscreen_x; - y = offscreen_y; - - x -= child_area.width / 2; - y -= child_area.height / 2; - - xr = x * c - y * s; - yr = x * s + y * c; - x = xr; - y = yr; - - x += child_area.width / 2; - y += child_area.height / 2; - - x -= (w - child_area.width) / 2; - y -= (h - child_area.height) / 2; - - *x_out = x; - *y_out = y; -} - -static void -gtk_rotated_bin_class_init (GtkRotatedBinClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - - widget_class->realize = gtk_rotated_bin_realize; - widget_class->unrealize = gtk_rotated_bin_unrealize; - widget_class->measure = gtk_rotated_bin_measure; - widget_class->size_allocate = gtk_rotated_bin_size_allocate; - widget_class->draw = gtk_rotated_bin_draw; - - g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET), - GTK_TYPE_ROTATED_BIN, - g_cclosure_new (G_CALLBACK (gtk_rotated_bin_damage), - NULL, NULL)); - - container_class->add = gtk_rotated_bin_add; - container_class->remove = gtk_rotated_bin_remove; - container_class->forall = gtk_rotated_bin_forall; - container_class->child_type = gtk_rotated_bin_child_type; -} - -static void -gtk_rotated_bin_init (GtkRotatedBin *bin) -{ - gtk_widget_set_has_window (GTK_WIDGET (bin), TRUE); -} - -GtkWidget * -gtk_rotated_bin_new (void) -{ - return g_object_new (GTK_TYPE_ROTATED_BIN, NULL); -} - -static GdkWindow * -pick_offscreen_child (GdkWindow *offscreen_window, - double widget_x, - double widget_y, - GtkRotatedBin *bin) -{ - GtkAllocation child_area; - double x, y; - - if (bin->child && gtk_widget_get_visible (bin->child)) - { - to_child (bin, widget_x, widget_y, &x, &y); - - gtk_widget_get_allocation (bin->child, &child_area); - - if (x >= 0 && x < child_area.width && - y >= 0 && y < child_area.height) - return bin->offscreen_window; - } - - return NULL; -} - -static void -offscreen_window_to_parent (GdkWindow *offscreen_window, - double offscreen_x, - double offscreen_y, - double *parent_x, - double *parent_y, - GtkRotatedBin *bin) -{ - to_parent (bin, offscreen_x, offscreen_y, parent_x, parent_y); -} - -static void -offscreen_window_from_parent (GdkWindow *window, - double parent_x, - double parent_y, - double *offscreen_x, - double *offscreen_y, - GtkRotatedBin *bin) -{ - to_child (bin, parent_x, parent_y, offscreen_x, offscreen_y); -} - -static void -gtk_rotated_bin_realize (GtkWidget *widget) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); - GtkAllocation allocation; - GdkWindow *window; - GdkWindowAttr attributes; - gint attributes_mask; - GtkRequisition child_requisition; - - gtk_widget_set_realized (widget, TRUE); - - gtk_widget_get_allocation (widget, &allocation); - - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_EXPOSURE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_SCROLL_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK; - - attributes.wclass = GDK_INPUT_OUTPUT; - - attributes_mask = GDK_WA_X | GDK_WA_Y; - - window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, window); - gdk_window_set_user_data (window, widget); - g_signal_connect (window, "pick-embedded-child", - G_CALLBACK (pick_offscreen_child), bin); - - attributes.window_type = GDK_WINDOW_OFFSCREEN; - - child_requisition.width = child_requisition.height = 0; - if (bin->child && gtk_widget_get_visible (bin->child)) - { - GtkAllocation child_allocation; - - gtk_widget_get_allocation (bin->child, &child_allocation); - attributes.width = child_allocation.width; - attributes.height = child_allocation.height; - } - bin->offscreen_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), - &attributes, attributes_mask); - gdk_window_set_user_data (bin->offscreen_window, widget); - if (bin->child) - gtk_widget_set_parent_window (bin->child, bin->offscreen_window); - gdk_offscreen_window_set_embedder (bin->offscreen_window, window); - g_signal_connect (bin->offscreen_window, "to-embedder", - G_CALLBACK (offscreen_window_to_parent), bin); - g_signal_connect (bin->offscreen_window, "from-embedder", - G_CALLBACK (offscreen_window_from_parent), bin); - - gdk_window_show (bin->offscreen_window); -} - -static void -gtk_rotated_bin_unrealize (GtkWidget *widget) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); - - gdk_window_set_user_data (bin->offscreen_window, NULL); - gdk_window_destroy (bin->offscreen_window); - bin->offscreen_window = NULL; - - GTK_WIDGET_CLASS (gtk_rotated_bin_parent_class)->unrealize (widget); -} - -static GType -gtk_rotated_bin_child_type (GtkContainer *container) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (container); - - if (bin->child) - return G_TYPE_NONE; - - return GTK_TYPE_WIDGET; -} - -static void -gtk_rotated_bin_add (GtkContainer *container, - GtkWidget *widget) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (container); - - if (!bin->child) - { - gtk_widget_set_parent_window (widget, bin->offscreen_window); - gtk_widget_set_parent (widget, GTK_WIDGET (bin)); - bin->child = widget; - } - else - g_warning ("GtkRotatedBin cannot have more than one child"); -} - -static void -gtk_rotated_bin_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (container); - gboolean was_visible; - - was_visible = gtk_widget_get_visible (widget); - - if (bin->child == widget) - { - gtk_widget_unparent (widget); - - bin->child = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } -} - -static void -gtk_rotated_bin_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (container); - - g_return_if_fail (callback != NULL); - - if (bin->child) - (*callback) (bin->child, callback_data); -} - -void -gtk_rotated_bin_set_angle (GtkRotatedBin *bin, - gdouble angle) -{ - g_return_if_fail (GTK_IS_ROTATED_BIN (bin)); - - bin->angle = angle; - gtk_widget_queue_resize (GTK_WIDGET (bin)); - - gdk_window_geometry_changed (bin->offscreen_window); -} - -static void -gtk_rotated_bin_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); - GtkRequisition child_requisition; - double s, c; - - child_requisition.width = 0; - child_requisition.height = 0; - - if (bin->child && gtk_widget_get_visible (bin->child)) - gtk_widget_get_preferred_size ( (bin->child), - &child_requisition, NULL); - - s = sin (bin->angle); - c = cos (bin->angle); - requisition->width = c * child_requisition.width + s * child_requisition.height; - requisition->height = s * child_requisition.width + c * child_requisition.height; -} - -static void -gtk_rotated_bin_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkRequisition requisition; - - gtk_rotated_bin_size_request (widget, &requisition); - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - *minimum = *natural = requisition.width; - else - *minimum = *natural = requisition.height; -} - -static void -gtk_rotated_bin_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); - gint w, h; - gdouble s, c; - - gtk_widget_set_allocation (widget, allocation); - - w = allocation->width; - h = allocation->height; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, - allocation->y, - w, h); - - if (bin->child && gtk_widget_get_visible (bin->child)) - { - GtkRequisition child_requisition; - GtkAllocation child_allocation; - - s = sin (bin->angle); - c = cos (bin->angle); - - gtk_widget_get_preferred_size (bin->child, - &child_requisition, NULL); - child_allocation.x = 0; - child_allocation.y = 0; - child_allocation.height = child_requisition.height; - if (c == 0.0) - child_allocation.width = h / s; - else if (s == 0.0) - child_allocation.width = w / c; - else - child_allocation.width = MIN ((w - s * child_allocation.height) / c, - (h - c * child_allocation.height) / s); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (bin->offscreen_window, - child_allocation.x, - child_allocation.y, - child_allocation.width, - child_allocation.height); - - child_allocation.x = child_allocation.y = 0; - gtk_widget_size_allocate (bin->child, &child_allocation); - } -} - -static gboolean -gtk_rotated_bin_damage (GtkWidget *widget, - GdkEventExpose *event) -{ - gdk_window_invalidate_rect (gtk_widget_get_window (widget), - NULL, FALSE); - - return TRUE; -} - -static gboolean -gtk_rotated_bin_draw (GtkWidget *widget, - cairo_t *cr) -{ - GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); - GdkWindow *window; - gdouble s, c; - gdouble w, h; - - window = gtk_widget_get_window (widget); - if (gtk_cairo_should_draw_window (cr, window)) - { - cairo_surface_t *surface; - GtkAllocation child_area; - - if (bin->child && gtk_widget_get_visible (bin->child)) - { - surface = gdk_offscreen_window_get_surface (bin->offscreen_window); - gtk_widget_get_allocation (bin->child, &child_area); - - /* transform */ - s = sin (bin->angle); - c = cos (bin->angle); - w = c * child_area.width + s * child_area.height; - h = s * child_area.width + c * child_area.height; - - cairo_translate (cr, (w - child_area.width) / 2, (h - child_area.height) / 2); - cairo_translate (cr, child_area.width / 2, child_area.height / 2); - cairo_rotate (cr, bin->angle); - cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); - - /* clip */ - cairo_rectangle (cr, - 0, 0, - gdk_window_get_width (bin->offscreen_window), - gdk_window_get_height (bin->offscreen_window)); - cairo_clip (cr); - /* paint */ - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - } - } - if (gtk_cairo_should_draw_window (cr, bin->offscreen_window)) - { - gtk_render_background (gtk_widget_get_style_context (widget), - cr, - 0, 0, - gdk_window_get_width (bin->offscreen_window), - gdk_window_get_height (bin->offscreen_window)); - - if (bin->child) - gtk_container_propagate_draw (GTK_CONTAINER (widget), - bin->child, - cr); - } - - return FALSE; -} - -/*** ***/ - -static void -scale_changed (GtkRange *range, - GtkRotatedBin *bin) -{ - gtk_rotated_bin_set_angle (bin, gtk_range_get_value (range)); -} - -GtkWidget * -do_offscreen_window (GtkWidget *do_widget) -{ - static GtkWidget *window = NULL; - - if (!window) - { - GtkWidget *bin, *vbox, *scale, *button; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_screen (GTK_WINDOW (window), - gtk_widget_get_screen (do_widget)); - gtk_window_set_title (GTK_WINDOW (window), "Rotated Button"); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_widget_destroyed), &window); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, - 0, G_PI/2, 0.01); - gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); - - button = gtk_button_new_with_label ("A Button"); - bin = gtk_rotated_bin_new (); - - g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed), bin); - - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE); - gtk_box_pack_start (GTK_BOX (vbox), bin, TRUE, TRUE); - gtk_container_add (GTK_CONTAINER (bin), button); - } - - if (!gtk_widget_get_visible (window)) - gtk_widget_show_all (window); - else - gtk_widget_destroy (window); - - return window; -} diff --git a/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c deleted file mode 100644 index 22bbe5237e..0000000000 --- a/demos/gtk-demo/offscreen_window2.c +++ /dev/null @@ -1,503 +0,0 @@ -/* Offscreen Windows/Effects - * - * Offscreen windows can be used to render elements multiple times to achieve - * various effects. - */ -#include -#include - -#define GTK_TYPE_MIRROR_BIN (gtk_mirror_bin_get_type ()) -#define GTK_MIRROR_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MIRROR_BIN, GtkMirrorBin)) -#define GTK_MIRROR_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MIRROR_BIN, GtkMirrorBinClass)) -#define GTK_IS_MIRROR_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MIRROR_BIN)) -#define GTK_IS_MIRROR_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MIRROR_BIN)) -#define GTK_MIRROR_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MIRROR_BIN, GtkMirrorBinClass)) - -typedef struct _GtkMirrorBin GtkMirrorBin; -typedef struct _GtkMirrorBinClass GtkMirrorBinClass; - -struct _GtkMirrorBin -{ - GtkContainer container; - - GtkWidget *child; - GdkWindow *offscreen_window; -}; - -struct _GtkMirrorBinClass -{ - GtkContainerClass parent_class; -}; - -GType gtk_mirror_bin_get_type (void) G_GNUC_CONST; -GtkWidget* gtk_mirror_bin_new (void); - -/*** implementation ***/ - -static void gtk_mirror_bin_realize (GtkWidget *widget); -static void gtk_mirror_bin_unrealize (GtkWidget *widget); -static void gtk_mirror_bin_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline); -static void gtk_mirror_bin_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean gtk_mirror_bin_damage (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_mirror_bin_draw (GtkWidget *widget, - cairo_t *cr); - -static void gtk_mirror_bin_add (GtkContainer *container, - GtkWidget *child); -static void gtk_mirror_bin_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_mirror_bin_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gtk_mirror_bin_child_type (GtkContainer *container); - -G_DEFINE_TYPE (GtkMirrorBin, gtk_mirror_bin, GTK_TYPE_CONTAINER); - -static void -to_child (GtkMirrorBin *bin, - double widget_x, - double widget_y, - double *x_out, - double *y_out) -{ - *x_out = widget_x; - *y_out = widget_y; -} - -static void -to_parent (GtkMirrorBin *bin, - double offscreen_x, - double offscreen_y, - double *x_out, - double *y_out) -{ - *x_out = offscreen_x; - *y_out = offscreen_y; -} - -static void -gtk_mirror_bin_class_init (GtkMirrorBinClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - - widget_class->realize = gtk_mirror_bin_realize; - widget_class->unrealize = gtk_mirror_bin_unrealize; - widget_class->measure = gtk_mirror_bin_measure; - widget_class->size_allocate = gtk_mirror_bin_size_allocate; - widget_class->draw = gtk_mirror_bin_draw; - - g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET), - GTK_TYPE_MIRROR_BIN, - g_cclosure_new (G_CALLBACK (gtk_mirror_bin_damage), - NULL, NULL)); - - container_class->add = gtk_mirror_bin_add; - container_class->remove = gtk_mirror_bin_remove; - container_class->forall = gtk_mirror_bin_forall; - container_class->child_type = gtk_mirror_bin_child_type; -} - -static void -gtk_mirror_bin_init (GtkMirrorBin *bin) -{ - gtk_widget_set_has_window (GTK_WIDGET (bin), TRUE); -} - -GtkWidget * -gtk_mirror_bin_new (void) -{ - return g_object_new (GTK_TYPE_MIRROR_BIN, NULL); -} - -static GdkWindow * -pick_offscreen_child (GdkWindow *offscreen_window, - double widget_x, - double widget_y, - GtkMirrorBin *bin) -{ - GtkAllocation child_area; - double x, y; - - if (bin->child && gtk_widget_get_visible (bin->child)) - { - to_child (bin, widget_x, widget_y, &x, &y); - - gtk_widget_get_allocation (bin->child, &child_area); - - if (x >= 0 && x < child_area.width && - y >= 0 && y < child_area.height) - return bin->offscreen_window; - } - - return NULL; -} - -static void -offscreen_window_to_parent (GdkWindow *offscreen_window, - double offscreen_x, - double offscreen_y, - double *parent_x, - double *parent_y, - GtkMirrorBin *bin) -{ - to_parent (bin, offscreen_x, offscreen_y, parent_x, parent_y); -} - -static void -offscreen_window_from_parent (GdkWindow *window, - double parent_x, - double parent_y, - double *offscreen_x, - double *offscreen_y, - GtkMirrorBin *bin) -{ - to_child (bin, parent_x, parent_y, offscreen_x, offscreen_y); -} - -static void -gtk_mirror_bin_realize (GtkWidget *widget) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); - GtkAllocation allocation; - GdkWindow *window; - GdkWindowAttr attributes; - gint attributes_mask; - GtkRequisition child_requisition; - - gtk_widget_set_realized (widget, TRUE); - - gtk_widget_get_allocation (widget, &allocation); - - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_EXPOSURE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_SCROLL_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK; - - attributes.wclass = GDK_INPUT_OUTPUT; - - attributes_mask = GDK_WA_X | GDK_WA_Y; - - window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, window); - gdk_window_set_user_data (window, widget); - g_signal_connect (window, "pick-embedded-child", - G_CALLBACK (pick_offscreen_child), bin); - - attributes.window_type = GDK_WINDOW_OFFSCREEN; - - child_requisition.width = child_requisition.height = 0; - if (bin->child && gtk_widget_get_visible (bin->child)) - { - GtkAllocation child_allocation; - - gtk_widget_get_allocation (bin->child, &child_allocation); - attributes.width = child_allocation.width; - attributes.height = child_allocation.height; - } - bin->offscreen_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), - &attributes, attributes_mask); - gdk_window_set_user_data (bin->offscreen_window, widget); - if (bin->child) - gtk_widget_set_parent_window (bin->child, bin->offscreen_window); - gdk_offscreen_window_set_embedder (bin->offscreen_window, window); - g_signal_connect (bin->offscreen_window, "to-embedder", - G_CALLBACK (offscreen_window_to_parent), bin); - g_signal_connect (bin->offscreen_window, "from-embedder", - G_CALLBACK (offscreen_window_from_parent), bin); - - gdk_window_show (bin->offscreen_window); -} - -static void -gtk_mirror_bin_unrealize (GtkWidget *widget) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); - - gdk_window_set_user_data (bin->offscreen_window, NULL); - gdk_window_destroy (bin->offscreen_window); - bin->offscreen_window = NULL; - - GTK_WIDGET_CLASS (gtk_mirror_bin_parent_class)->unrealize (widget); -} - -static GType -gtk_mirror_bin_child_type (GtkContainer *container) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (container); - - if (bin->child) - return G_TYPE_NONE; - - return GTK_TYPE_WIDGET; -} - -static void -gtk_mirror_bin_add (GtkContainer *container, - GtkWidget *widget) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (container); - - if (!bin->child) - { - gtk_widget_set_parent_window (widget, bin->offscreen_window); - gtk_widget_set_parent (widget, GTK_WIDGET (bin)); - bin->child = widget; - } - else - g_warning ("GtkMirrorBin cannot have more than one child"); -} - -static void -gtk_mirror_bin_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (container); - gboolean was_visible; - - was_visible = gtk_widget_get_visible (widget); - - if (bin->child == widget) - { - gtk_widget_unparent (widget); - - bin->child = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } -} - -static void -gtk_mirror_bin_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (container); - - g_return_if_fail (callback != NULL); - - if (bin->child) - (*callback) (bin->child, callback_data); -} - -static void -gtk_mirror_bin_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); - GtkRequisition child_requisition; - - child_requisition.width = 0; - child_requisition.height = 0; - - if (bin->child && gtk_widget_get_visible (bin->child)) - gtk_widget_get_preferred_size ( (bin->child), - &child_requisition, NULL); - - requisition->width = child_requisition.width + 10; - requisition->height = child_requisition.height * 2 + 10; -} - -static void -gtk_mirror_bin_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkRequisition requisition; - - gtk_mirror_bin_size_request (widget, &requisition); - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - *minimum = *natural = requisition.width; - else - *minimum = *natural = requisition.height; -} - -static void -gtk_mirror_bin_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); - gint w, h; - - gtk_widget_set_allocation (widget, allocation); - - w = allocation->width; - h = allocation->height; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, - allocation->y, - w, h); - - if (bin->child && gtk_widget_get_visible (bin->child)) - { - GtkRequisition child_requisition; - GtkAllocation child_allocation; - - gtk_widget_get_preferred_size (bin->child, - &child_requisition, NULL); - child_allocation.x = 0; - child_allocation.y = 0; - child_allocation.height = child_requisition.height; - child_allocation.width = child_requisition.width; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (bin->offscreen_window, - allocation->x, - allocation->y, - child_allocation.width, child_allocation.height); - gtk_widget_size_allocate (bin->child, &child_allocation); - } -} - -static gboolean -gtk_mirror_bin_damage (GtkWidget *widget, - GdkEventExpose *event) -{ - gdk_window_invalidate_rect (gtk_widget_get_window (widget), - NULL, FALSE); - - return TRUE; -} - -static gboolean -gtk_mirror_bin_draw (GtkWidget *widget, - cairo_t *cr) -{ - GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); - GdkWindow *window; - - window = gtk_widget_get_window (widget); - if (gtk_cairo_should_draw_window (cr, window)) - { - cairo_surface_t *surface; - cairo_matrix_t matrix; - cairo_pattern_t *mask; - int height; - - if (bin->child && gtk_widget_get_visible (bin->child)) - { - surface = gdk_offscreen_window_get_surface (bin->offscreen_window); - height = gdk_window_get_height (bin->offscreen_window); - - /* paint the offscreen child */ - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - - cairo_matrix_init (&matrix, 1.0, 0.0, 0.3, 1.0, 0.0, 0.0); - cairo_matrix_scale (&matrix, 1.0, -1.0); - cairo_matrix_translate (&matrix, -10, - 3 * height - 10); - cairo_transform (cr, &matrix); - - cairo_set_source_surface (cr, surface, 0, height); - - /* create linear gradient as mask-pattern to fade out the source */ - mask = cairo_pattern_create_linear (0.0, height, 0.0, 2*height); - cairo_pattern_add_color_stop_rgba (mask, 0.0, 0.0, 0.0, 0.0, 0.0); - cairo_pattern_add_color_stop_rgba (mask, 0.25, 0.0, 0.0, 0.0, 0.01); - cairo_pattern_add_color_stop_rgba (mask, 0.5, 0.0, 0.0, 0.0, 0.25); - cairo_pattern_add_color_stop_rgba (mask, 0.75, 0.0, 0.0, 0.0, 0.5); - cairo_pattern_add_color_stop_rgba (mask, 1.0, 0.0, 0.0, 0.0, 1.0); - - /* paint the reflection */ - cairo_mask (cr, mask); - - cairo_pattern_destroy (mask); - } - } - else if (gtk_cairo_should_draw_window (cr, bin->offscreen_window)) - { - gtk_render_background (gtk_widget_get_style_context (widget), - cr, - 0, 0, - gdk_window_get_width (bin->offscreen_window), - gdk_window_get_height (bin->offscreen_window)); - - if (bin->child) - gtk_container_propagate_draw (GTK_CONTAINER (widget), - bin->child, - cr); - } - - return FALSE; -} - -/*** ***/ - -GtkWidget * -do_offscreen_window2 (GtkWidget *do_widget) -{ - static GtkWidget *window = NULL; - - if (!window) - { - GtkWidget *bin, *vbox; - GtkWidget *hbox, *entry, *applybutton, *backbutton; - GtkSizeGroup *group; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_screen (GTK_WINDOW (window), - gtk_widget_get_screen (do_widget)); - gtk_window_set_title (GTK_WINDOW (window), "Effects"); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_widget_destroyed), &window); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - - bin = gtk_mirror_bin_new (); - - group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - backbutton = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (backbutton), - gtk_image_new_from_icon_name ("go-previous", 4)); - gtk_size_group_add_widget (group, backbutton); - entry = gtk_entry_new (); - gtk_size_group_add_widget (group, entry); - applybutton = gtk_button_new_with_label (_("Apply")); - gtk_size_group_add_widget (group, applybutton); - - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_box_pack_start (GTK_BOX (vbox), bin, TRUE, TRUE); - gtk_container_add (GTK_CONTAINER (bin), hbox); - gtk_box_pack_start (GTK_BOX (hbox), backbutton, FALSE, FALSE); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE); - gtk_box_pack_start (GTK_BOX (hbox), applybutton, FALSE, FALSE); - } - - if (!gtk_widget_get_visible (window)) - gtk_widget_show_all (window); - else - gtk_widget_destroy (window); - - return window; -} diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 079fca6a2b..d6fda17e70 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -484,14 +484,8 @@ gdk_window_get_event_compression gdk_window_set_event_compression -gdk_offscreen_window_get_surface -gdk_offscreen_window_set_embedder -gdk_offscreen_window_get_embedder -gdk_window_geometry_changed gdk_window_coords_from_parent gdk_window_coords_to_parent -gdk_window_get_effective_parent -gdk_window_get_effective_toplevel GDK_WINDOW diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml index 0e5030b6a6..749d88093f 100644 --- a/docs/reference/gtk/gtk-docs.sgml +++ b/docs/reference/gtk/gtk-docs.sgml @@ -62,7 +62,6 @@ - diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index a159bdde8c..55af959fda 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -2122,26 +2122,6 @@ GtkNotebookTab GtkNotebookPrivate -
-gtkoffscreenwindow -GtkOffscreenWindow -GtkOffscreenWindow -GtkOffscreenWindowClass -gtk_offscreen_window_new -gtk_offscreen_window_get_surface -gtk_offscreen_window_get_pixbuf - -GTK_OFFSCREEN_WINDOW -GTK_IS_OFFSCREEN_WINDOW -GTK_TYPE_OFFSCREEN_WINDOW -GTK_OFFSCREEN_WINDOW_CLASS -GTK_IS_OFFSCREEN_WINDOW_CLASS -GTK_OFFSCREEN_WINDOW_GET_CLASS - - -gtk_offscreen_window_get_type -
-
gtkpaned GtkPaned diff --git a/gdk/Makefile.am b/gdk/Makefile.am index d309089b42..538d113a65 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -161,7 +161,6 @@ gdk_c_sources = \ gdkkeys.c \ gdkkeyuni.c \ gdkmonitor.c \ - gdkoffscreenwindow.c \ gdkframeclock.c \ gdkframeclockidle.c \ gdkpango.c \ diff --git a/gdk/broadway/gdkdisplay-broadway.h b/gdk/broadway/gdkdisplay-broadway.h index 38a9968ad7..d8b094cd6e 100644 --- a/gdk/broadway/gdkdisplay-broadway.h +++ b/gdk/broadway/gdkdisplay-broadway.h @@ -51,9 +51,6 @@ struct _GdkBroadwayDisplay /* drag and drop information */ GdkDragContext *current_dest_drag; - /* The offscreen window that has the pointer in it (if any) */ - GdkWindow *active_offscreen_window; - GdkBroadwayServer *server; gpointer move_resize_data; diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c index 7b478ce7fc..9044144a1c 100644 --- a/gdk/broadway/gdkwindow-broadway.c +++ b/gdk/broadway/gdkwindow-broadway.c @@ -48,13 +48,11 @@ static void gdk_window_impl_broadway_finalize (GObject *obje static const cairo_user_data_key_t gdk_broadway_cairo_key; #define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \ - (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD) #define WINDOW_IS_TOPLEVEL(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) struct _GdkBroadwayWindow { GdkWindow parent; diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index e489d5a95a..13451a5400 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -1456,18 +1456,6 @@ gdk_device_grab (GdkDevice *device, native = gdk_window_get_toplevel (window); - while (native->window_type == GDK_WINDOW_OFFSCREEN) - { - native = gdk_offscreen_window_get_embedder (native); - - if (native == NULL || - (!_gdk_window_has_impl (native) && - !gdk_window_is_viewable (native))) - return GDK_GRAB_NOT_VIEWABLE; - - native = gdk_window_get_toplevel (native); - } - if (native == NULL || GDK_WINDOW_DESTROYED (native)) return GDK_GRAB_NOT_VIEWABLE; diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index ad59f76777..b9b113cd57 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -309,8 +309,6 @@ struct _GdkWindow gint shadow_right; gint shadow_bottom; - guint num_offscreen_children; - /* The clip region is the part of the window, in window coordinates that is fully or partially (i.e. semi transparently) visible in the window hierarchy from the toplevel and down */ @@ -492,17 +490,6 @@ void _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_win gboolean _gdk_window_has_impl (GdkWindow *window); GdkWindow * _gdk_window_get_impl_window (GdkWindow *window); -/***************************** - * offscreen window routines * - *****************************/ -GType gdk_offscreen_window_get_type (void); -void _gdk_offscreen_window_new (GdkWindow *window, - GdkWindowAttr *attributes, - gint attributes_mask); -cairo_surface_t * _gdk_offscreen_window_create_surface (GdkWindow *window, - gint width, - gint height); - G_END_DECLS #endif /* __GDK_INTERNALS_H__ */ diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c deleted file mode 100644 index 16ae806f11..0000000000 --- a/gdk/gdkoffscreenwindow.c +++ /dev/null @@ -1,764 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2005. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gdkwindow.h" -#include "gdkinternals.h" -#include "gdkwindowimpl.h" - -#include - -#include "fallback-c89.c" - -/* LIMITATIONS: - * - * Offscreen windows can’t be the child of a foreign window, - * nor contain foreign windows - * GDK_POINTER_MOTION_HINT_MASK isn't effective - */ - -typedef struct _GdkOffscreenWindow GdkOffscreenWindow; -typedef struct _GdkOffscreenWindowClass GdkOffscreenWindowClass; - -struct _GdkOffscreenWindow -{ - GdkWindowImpl parent_instance; - - GdkWindow *wrapper; - - cairo_surface_t *surface; - GdkWindow *embedder; -}; - -struct _GdkOffscreenWindowClass -{ - GdkWindowImplClass parent_class; -}; - -#define GDK_TYPE_OFFSCREEN_WINDOW (gdk_offscreen_window_get_type()) -#define GDK_OFFSCREEN_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindow)) -#define GDK_IS_OFFSCREEN_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_OFFSCREEN_WINDOW)) -#define GDK_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass)) -#define GDK_IS_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_OFFSCREEN_WINDOW)) -#define GDK_OFFSCREEN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass)) - -static void gdk_offscreen_window_hide (GdkWindow *window); - -G_DEFINE_TYPE (GdkOffscreenWindow, gdk_offscreen_window, GDK_TYPE_WINDOW_IMPL) - - -static void -gdk_offscreen_window_finalize (GObject *object) -{ - GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (object); - - if (offscreen->surface) - cairo_surface_destroy (offscreen->surface); - - G_OBJECT_CLASS (gdk_offscreen_window_parent_class)->finalize (object); -} - -static void -gdk_offscreen_window_init (GdkOffscreenWindow *window) -{ -} - -static void -gdk_offscreen_window_destroy (GdkWindow *window, - gboolean recursing, - gboolean foreign_destroy) -{ - gdk_offscreen_window_set_embedder (window, NULL); - - if (!recursing) - gdk_offscreen_window_hide (window); -} - -static cairo_surface_t * -get_surface (GdkOffscreenWindow *offscreen) -{ - if (! offscreen->surface) - { - GdkWindow *window = offscreen->wrapper; - - g_signal_emit_by_name (window, "create-surface", - window->width, - window->height, - &offscreen->surface); - } - - return offscreen->surface; -} - -static gboolean -is_parent_of (GdkWindow *parent, - GdkWindow *child) -{ - GdkWindow *w; - - w = child; - while (w != NULL) - { - if (w == parent) - return TRUE; - - w = gdk_window_get_parent (w); - } - - return FALSE; -} - -static cairo_surface_t * -gdk_offscreen_window_ref_cairo_surface (GdkWindow *window) -{ - GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - - return cairo_surface_reference (get_surface (offscreen)); -} - -cairo_surface_t * -_gdk_offscreen_window_create_surface (GdkWindow *offscreen, - gint width, - gint height) -{ - GdkOffscreenWindow *impl; - GdkWindow *derived; - - g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL); - - impl = GDK_OFFSCREEN_WINDOW (offscreen->impl); - derived = impl->embedder ? impl->embedder : offscreen->parent; - - return gdk_window_create_similar_surface (derived, - CAIRO_CONTENT_COLOR_ALPHA, - width, height); -} - -void -_gdk_offscreen_window_new (GdkWindow *window, - GdkWindowAttr *attributes, - gint attributes_mask) -{ - GdkOffscreenWindow *offscreen; - - g_return_if_fail (attributes != NULL); - - if (attributes->wclass != GDK_INPUT_OUTPUT) - return; /* Can't support input only offscreens */ - - if (window->parent != NULL && GDK_WINDOW_DESTROYED (window->parent)) - return; - - window->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL); - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - offscreen->wrapper = window; -} - -static gboolean -gdk_offscreen_window_reparent (GdkWindow *window, - GdkWindow *new_parent, - gint x, - gint y) -{ - GdkWindow *old_parent; - gboolean was_mapped; - - if (new_parent) - { - /* No input-output children of input-only windows */ - if (new_parent->input_only && !window->input_only) - return FALSE; - - /* Don't create loops in hierarchy */ - if (is_parent_of (window, new_parent)) - return FALSE; - } - - was_mapped = GDK_WINDOW_IS_MAPPED (window); - - gdk_window_hide (window); - - if (window->parent) - window->parent->children = g_list_remove_link (window->parent->children, &window->children_list_node); - - old_parent = window->parent; - window->parent = new_parent; - window->x = x; - window->y = y; - - if (new_parent) - window->parent->children = g_list_concat (&window->children_list_node, window->parent->children); - - _gdk_synthesize_crossing_events_for_geometry_change (window); - if (old_parent) - _gdk_synthesize_crossing_events_for_geometry_change (old_parent); - - return was_mapped; -} - -static void -gdk_offscreen_window_set_device_cursor (GdkWindow *window, - GdkDevice *device, - GdkCursor *cursor) -{ -} - -static void -from_embedder (GdkWindow *window, - double embedder_x, double embedder_y, - double *offscreen_x, double *offscreen_y) -{ - g_signal_emit_by_name (window->impl_window, - "from-embedder", - embedder_x, embedder_y, - offscreen_x, offscreen_y, - NULL); -} - -static void -to_embedder (GdkWindow *window, - double offscreen_x, double offscreen_y, - double *embedder_x, double *embedder_y) -{ - g_signal_emit_by_name (window->impl_window, - "to-embedder", - offscreen_x, offscreen_y, - embedder_x, embedder_y, - NULL); -} - -static void -gdk_offscreen_window_get_root_coords (GdkWindow *window, - gint x, - gint y, - gint *root_x, - gint *root_y) -{ - GdkOffscreenWindow *offscreen; - int tmpx, tmpy; - - tmpx = x; - tmpy = y; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - if (offscreen->embedder) - { - double dx, dy; - to_embedder (window, - x, y, - &dx, &dy); - tmpx = floor (dx + 0.5); - tmpy = floor (dy + 0.5); - gdk_window_get_root_coords (offscreen->embedder, - tmpx, tmpy, - &tmpx, &tmpy); - - } - - if (root_x) - *root_x = tmpx; - if (root_y) - *root_y = tmpy; -} - -static gboolean -gdk_offscreen_window_get_device_state (GdkWindow *window, - GdkDevice *device, - gdouble *x, - gdouble *y, - GdkModifierType *mask) -{ - GdkOffscreenWindow *offscreen; - double tmpx, tmpy; - double dtmpx, dtmpy; - GdkModifierType tmpmask; - - tmpx = 0; - tmpy = 0; - tmpmask = 0; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - if (offscreen->embedder != NULL) - { - gdk_window_get_device_position_double (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask); - from_embedder (window, - tmpx, tmpy, - &dtmpx, &dtmpy); - tmpx = dtmpx; - tmpy = dtmpy; - } - - if (x) - *x = round (tmpx); - if (y) - *y = round (tmpy); - if (mask) - *mask = tmpmask; - return TRUE; -} - -/** - * gdk_offscreen_window_get_surface: - * @window: a #GdkWindow - * - * Gets the offscreen surface that an offscreen window renders into. - * If you need to keep this around over window resizes, you need to - * add a reference to it. - * - * Returns: (nullable) (transfer none): The offscreen surface, or - * %NULL if not offscreen - */ -cairo_surface_t * -gdk_offscreen_window_get_surface (GdkWindow *window) -{ - GdkOffscreenWindow *offscreen; - - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - - if (!GDK_IS_OFFSCREEN_WINDOW (window->impl)) - return NULL; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - - return get_surface (offscreen); -} - -static void -gdk_offscreen_window_raise (GdkWindow *window) -{ - /* gdk_window_raise already changed the stacking order */ - _gdk_synthesize_crossing_events_for_geometry_change (window); -} - -static void -gdk_offscreen_window_lower (GdkWindow *window) -{ - /* gdk_window_lower already changed the stacking order */ - _gdk_synthesize_crossing_events_for_geometry_change (window); -} - -static void -gdk_offscreen_window_move_resize_internal (GdkWindow *window, - gint x, - gint y, - gint width, - gint height, - gboolean send_expose_events) -{ - GdkOffscreenWindow *offscreen; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - - if (width < 1) - width = 1; - if (height < 1) - height = 1; - - if (window->destroyed) - return; - - window->x = x; - window->y = y; - - if (window->width != width || - window->height != height) - { - window->width = width; - window->height = height; - - if (offscreen->surface) - { - cairo_surface_t *old_surface; - cairo_t *cr; - - old_surface = offscreen->surface; - offscreen->surface = NULL; - - offscreen->surface = get_surface (offscreen); - - cr = cairo_create (offscreen->surface); - cairo_set_source_surface (cr, old_surface, 0, 0); - cairo_paint (cr); - cairo_destroy (cr); - - cairo_surface_destroy (old_surface); - } - } - - if (GDK_WINDOW_IS_MAPPED (window)) - { - /* TODO: Only invalidate new area, i.e. for larger windows */ - gdk_window_invalidate_rect (window, NULL, TRUE); - _gdk_synthesize_crossing_events_for_geometry_change (window); - } -} - -static void -gdk_offscreen_window_move_resize (GdkWindow *window, - gboolean with_move, - gint x, - gint y, - gint width, - gint height) -{ - if (!with_move) - { - x = window->x; - y = window->y; - } - - if (width < 0) - width = window->width; - - if (height < 0) - height = window->height; - - gdk_offscreen_window_move_resize_internal (window, - x, y, width, height, - TRUE); -} - -static void -gdk_offscreen_window_show (GdkWindow *window, - gboolean already_mapped) -{ - GdkRectangle area = { 0, 0, window->width, window->height }; - - gdk_window_invalidate_rect (window, &area, FALSE); -} - - -static void -gdk_offscreen_window_hide (GdkWindow *window) -{ - /* TODO: This needs updating to the new grab world */ -#if 0 - GdkOffscreenWindow *offscreen; - GdkDisplay *display; - - g_return_if_fail (window != NULL); - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - - /* May need to break grabs on children */ - display = gdk_window_get_display (window); - - if (display->pointer_grab.window != NULL) - { - if (is_parent_of (window, display->pointer_grab.window)) - { - /* Call this ourselves, even though gdk_display_pointer_ungrab - does so too, since we want to pass implicit == TRUE so the - broken grab event is generated */ - _gdk_display_unset_has_pointer_grab (display, - TRUE, - FALSE, - GDK_CURRENT_TIME); - gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME); - } - } -#endif -} - -static void -gdk_offscreen_window_withdraw (GdkWindow *window) -{ -} - -static GdkEventMask -gdk_offscreen_window_get_events (GdkWindow *window) -{ - return 0; -} - -static void -gdk_offscreen_window_set_events (GdkWindow *window, - GdkEventMask event_mask) -{ -} - -static void -gdk_offscreen_window_shape_combine_region (GdkWindow *window, - const cairo_region_t *shape_region, - gint offset_x, - gint offset_y) -{ -} - -static void -gdk_offscreen_window_input_shape_combine_region (GdkWindow *window, - const cairo_region_t *shape_region, - gint offset_x, - gint offset_y) -{ -} - -static void -gdk_offscreen_window_get_geometry (GdkWindow *window, - gint *x, - gint *y, - gint *width, - gint *height) -{ - if (!GDK_WINDOW_DESTROYED (window)) - { - if (x) - *x = window->x; - if (y) - *y = window->y; - if (width) - *width = window->width; - if (height) - *height = window->height; - } -} - -static void -gdk_offscreen_window_queue_antiexpose (GdkWindow *window, - cairo_region_t *area) -{ -} - -/** - * gdk_offscreen_window_set_embedder: - * @window: a #GdkWindow - * @embedder: the #GdkWindow that @window gets embedded in - * - * Sets @window to be embedded in @embedder. - * - * To fully embed an offscreen window, in addition to calling this - * function, it is also necessary to handle the #GdkWindow::pick-embedded-child - * signal on the @embedder and the #GdkWindow::to-embedder and - * #GdkWindow::from-embedder signals on @window. - * - * Since: 2.18 - */ -void -gdk_offscreen_window_set_embedder (GdkWindow *window, - GdkWindow *embedder) -{ - GdkOffscreenWindow *offscreen; - - g_return_if_fail (GDK_IS_WINDOW (window)); - - if (!GDK_IS_OFFSCREEN_WINDOW (window->impl)) - return; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - - if (embedder) - { - g_object_ref (embedder); - embedder->num_offscreen_children++; - } - - if (offscreen->embedder) - { - g_object_unref (offscreen->embedder); - offscreen->embedder->num_offscreen_children--; - } - - offscreen->embedder = embedder; -} - -/** - * gdk_offscreen_window_get_embedder: - * @window: a #GdkWindow - * - * Gets the window that @window is embedded in. - * - * Returns: (nullable) (transfer none): the embedding #GdkWindow, or - * %NULL if @window is not an mbedded offscreen window - * - * Since: 2.18 - */ -GdkWindow * -gdk_offscreen_window_get_embedder (GdkWindow *window) -{ - GdkOffscreenWindow *offscreen; - - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - - if (!GDK_IS_OFFSCREEN_WINDOW (window->impl)) - return NULL; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - - return offscreen->embedder; -} - -static void -gdk_offscreen_window_do_nothing (GdkWindow *window) -{ -} - -static void -gdk_offscreen_window_set_boolean (GdkWindow *window, - gboolean setting) -{ -} - -static void -gdk_offscreen_window_set_string (GdkWindow *window, - const gchar *setting) -{ -} - -static void -gdk_offscreen_window_set_list (GdkWindow *window, - GList *list) -{ -} - -static void -gdk_offscreen_window_set_wmfunctions (GdkWindow *window, - GdkWMFunction functions) -{ -} - -static void -gdk_offscreen_window_set_transient_for (GdkWindow *window, - GdkWindow *another) -{ -} - -static void -gdk_offscreen_window_get_frame_extents (GdkWindow *window, - GdkRectangle *rect) -{ - rect->x = window->x; - rect->y = window->y; - rect->width = window->width; - rect->height = window->height; -} - -static gint -gdk_offscreen_window_get_scale_factor (GdkWindow *window) -{ - GdkOffscreenWindow *offscreen; - - if (GDK_WINDOW_DESTROYED (window)) - return 1; - - offscreen = GDK_OFFSCREEN_WINDOW (window->impl); - if (offscreen->embedder) - return gdk_window_get_scale_factor (offscreen->embedder); - - return gdk_window_get_scale_factor (window->parent); -} - -static void -gdk_offscreen_window_set_opacity (GdkWindow *window, gdouble opacity) -{ -} - -static gboolean -gdk_offscreen_window_beep (GdkWindow *window) -{ - return FALSE; -} - -static void -gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass) -{ - GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gdk_offscreen_window_finalize; - - impl_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface; - impl_class->show = gdk_offscreen_window_show; - impl_class->hide = gdk_offscreen_window_hide; - impl_class->withdraw = gdk_offscreen_window_withdraw; - impl_class->set_events = gdk_offscreen_window_set_events; - impl_class->get_events = gdk_offscreen_window_get_events; - impl_class->raise = gdk_offscreen_window_raise; - impl_class->lower = gdk_offscreen_window_lower; - impl_class->restack_under = NULL; - impl_class->restack_toplevel = NULL; - impl_class->move_resize = gdk_offscreen_window_move_resize; - impl_class->reparent = gdk_offscreen_window_reparent; - impl_class->set_device_cursor = gdk_offscreen_window_set_device_cursor; - impl_class->get_geometry = gdk_offscreen_window_get_geometry; - impl_class->get_root_coords = gdk_offscreen_window_get_root_coords; - impl_class->get_device_state = gdk_offscreen_window_get_device_state; - impl_class->shape_combine_region = gdk_offscreen_window_shape_combine_region; - impl_class->input_shape_combine_region = gdk_offscreen_window_input_shape_combine_region; - impl_class->queue_antiexpose = gdk_offscreen_window_queue_antiexpose; - impl_class->destroy = gdk_offscreen_window_destroy; - impl_class->destroy_foreign = NULL; - impl_class->get_shape = NULL; - impl_class->get_input_shape = NULL; - impl_class->beep = gdk_offscreen_window_beep; - - impl_class->focus = NULL; - impl_class->set_type_hint = NULL; - impl_class->get_type_hint = NULL; - impl_class->set_modal_hint = gdk_offscreen_window_set_boolean; - impl_class->set_skip_taskbar_hint = gdk_offscreen_window_set_boolean; - impl_class->set_skip_pager_hint = gdk_offscreen_window_set_boolean; - impl_class->set_urgency_hint = gdk_offscreen_window_set_boolean; - impl_class->set_geometry_hints = NULL; - impl_class->set_title = gdk_offscreen_window_set_string; - impl_class->set_role = gdk_offscreen_window_set_string; - impl_class->set_startup_id = gdk_offscreen_window_set_string; - impl_class->set_transient_for = gdk_offscreen_window_set_transient_for; - impl_class->get_frame_extents = gdk_offscreen_window_get_frame_extents; - impl_class->set_override_redirect = NULL; - impl_class->set_accept_focus = gdk_offscreen_window_set_boolean; - impl_class->set_focus_on_map = gdk_offscreen_window_set_boolean; - impl_class->set_icon_list = gdk_offscreen_window_set_list; - impl_class->set_icon_name = gdk_offscreen_window_set_string; - impl_class->iconify = gdk_offscreen_window_do_nothing; - impl_class->deiconify = gdk_offscreen_window_do_nothing; - impl_class->stick = gdk_offscreen_window_do_nothing; - impl_class->unstick = gdk_offscreen_window_do_nothing; - impl_class->maximize = gdk_offscreen_window_do_nothing; - impl_class->unmaximize = gdk_offscreen_window_do_nothing; - impl_class->fullscreen = gdk_offscreen_window_do_nothing; - impl_class->unfullscreen = gdk_offscreen_window_do_nothing; - impl_class->set_keep_above = gdk_offscreen_window_set_boolean; - impl_class->set_keep_below = gdk_offscreen_window_set_boolean; - impl_class->get_group = NULL; - impl_class->set_group = NULL; - impl_class->set_decorations = NULL; - impl_class->get_decorations = NULL; - impl_class->set_functions = gdk_offscreen_window_set_wmfunctions; - impl_class->begin_resize_drag = NULL; - impl_class->begin_move_drag = NULL; - impl_class->enable_synchronized_configure = gdk_offscreen_window_do_nothing; - impl_class->configure_finished = NULL; - impl_class->set_opacity = gdk_offscreen_window_set_opacity; - impl_class->destroy_notify = NULL; - impl_class->register_dnd = gdk_offscreen_window_do_nothing; - impl_class->drag_begin = NULL; - impl_class->sync_rendering = NULL; - impl_class->simulate_key = NULL; - impl_class->simulate_button = NULL; - impl_class->get_property = NULL; - impl_class->change_property = NULL; - impl_class->delete_property = NULL; - impl_class->get_scale_factor = gdk_offscreen_window_get_scale_factor; -} diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 6697a530b9..febc3c00ed 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -68,24 +68,6 @@ * window, the thing a user might think of as a “window” with a titlebar * and so on; a #GtkWindow may contain many #GdkWindows. For example, * each #GtkButton has a #GdkWindow associated with it. - * - * # Offscreen Windows # {#OFFSCREEN-WINDOWS} - * - * Offscreen windows are more general than composited windows, since - * they allow not only to modify the rendering of the child window onto - * its parent, but also to apply coordinate transformations. - * - * To integrate an offscreen window into a window hierarchy, one has - * to call gdk_offscreen_window_set_embedder() and handle a number of - * signals. The #GdkWindow::pick-embedded-child signal on the embedder - * window is used to select an offscreen child at given coordinates, - * and the #GdkWindow::to-embedder and #GdkWindow::from-embedder signals - * on the offscreen window are used to translate coordinates between - * the embedder and the offscreen window. - * - * For rendering an offscreen window onto its embedder, the contents - * of the offscreen window are available as a surface, via - * gdk_offscreen_window_get_surface(). */ @@ -95,23 +77,18 @@ * and the actual platform specific implementation was in a delegate * object available as “impl” in the window object. * - * With the addition of client side windows and offscreen windows this - * changes a bit. The application-visible GdkWindow object behaves as - * it did before, but not all such windows now have a corresponding native - * window. Instead windows that are “client side” are emulated by the gdk - * code such that clipping, drawing, moving, events etc work as expected. + * With the addition of client side windows this changes a bit. The + * application-visible GdkWindow object behaves as it did before, but + * not all such windows now have a corresponding native + * window. Instead windows that are “client side” are emulated by the + * gdk code such that clipping, drawing, moving, events etc work as + * expected. * * For GdkWindows that have a native window the “impl” object is the * same as before. However, for all client side windows the impl object * is shared with its parent (i.e. all client windows descendants of one * native window has the same impl. * - * Additionally there is a new type of platform independent impl object, - * GdkOffscreenWindow. All windows of type GDK_WINDOW_OFFSCREEN get an impl - * of this type (while their children are generally GDK_WINDOW_CHILD virtual - * windows). Such windows work by allocating a #cairo_surface_t as the backing - * store for drawing operations, which is resized with the window. - * * GdkWindows have a pointer to the “impl window” they are in, i.e. * the topmost GdkWindow which have the same “impl” value. This is stored * in impl_window, which is different from the window itself only for client @@ -121,10 +98,10 @@ * with respect to the impl window (abs_x, abs_y). We also track the clip * region of the window wrt parent windows, in window-relative coordinates (clip_region). * - * All toplevel windows are native windows, but also child windows can be - * native (although not children of offscreens). We always listen to - * a basic set of events (see get_native_event_mask) for these windows - * so that we can emulate events for any client side children. + * All toplevel windows are native windows, but also child windows can + * be native. We always listen to a basic set of events (see + * get_native_event_mask) for these windows so that we can emulate + * events for any client side children. * * For native windows we apply the calculated clip region as a window shape * so that eg. client side siblings that overlap the native child properly @@ -135,10 +112,6 @@ #define GDK_VISIBILITY_NOT_VIEWABLE 3 enum { - PICK_EMBEDDED_CHILD, /* only called if children are embedded */ - TO_EMBEDDER, - FROM_EMBEDDER, - CREATE_SURFACE, MOVED_TO_RECT, LAST_SIGNAL }; @@ -286,30 +259,6 @@ gdk_window_init (GdkWindow *window) NULL, g_object_unref); } -/* Stop and return on the first non-NULL parent */ -static gboolean -accumulate_get_window (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer data) -{ - g_value_copy (handler_return, return_accu); - /* Continue while returning NULL */ - return g_value_get_object (handler_return) == NULL; -} - -static gboolean -create_surface_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer data) -{ - g_value_copy (handler_return, return_accu); - - /* Stop on the first non-NULL return value */ - return g_value_get_boxed (handler_return) == NULL; -} - static GQuark quark_pointer_window = 0; static void @@ -321,8 +270,6 @@ gdk_window_class_init (GdkWindowClass *klass) object_class->set_property = gdk_window_set_property; object_class->get_property = gdk_window_get_property; - klass->create_surface = _gdk_offscreen_window_create_surface; - quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window"); @@ -344,127 +291,6 @@ gdk_window_class_init (GdkWindowClass *klass) G_PARAM_READWRITE); g_object_class_install_properties (object_class, LAST_PROP, properties); - /** - * GdkWindow::pick-embedded-child: - * @window: the window on which the signal is emitted - * @x: x coordinate in the window - * @y: y coordinate in the window - * - * The ::pick-embedded-child signal is emitted to find an embedded - * child at the given position. - * - * Returns: (nullable) (transfer none): the #GdkWindow of the - * embedded child at @x, @y, or %NULL - * - * Since: 2.18 - */ - signals[PICK_EMBEDDED_CHILD] = - g_signal_new (g_intern_static_string ("pick-embedded-child"), - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowClass, pick_embedded_child), - accumulate_get_window, NULL, - _gdk_marshal_OBJECT__DOUBLE_DOUBLE, - GDK_TYPE_WINDOW, - 2, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE); - - /** - * GdkWindow::to-embedder: - * @window: the offscreen window on which the signal is emitted - * @offscreen_x: x coordinate in the offscreen window - * @offscreen_y: y coordinate in the offscreen window - * @embedder_x: (out) (type double): return location for the x - * coordinate in the embedder window - * @embedder_y: (out) (type double): return location for the y - * coordinate in the embedder window - * - * The ::to-embedder signal is emitted to translate coordinates - * in an offscreen window to its embedder. - * - * See also #GdkWindow::from-embedder. - * - * Since: 2.18 - */ - signals[TO_EMBEDDER] = - g_signal_new (g_intern_static_string ("to-embedder"), - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowClass, to_embedder), - NULL, NULL, - _gdk_marshal_VOID__DOUBLE_DOUBLE_POINTER_POINTER, - G_TYPE_NONE, - 4, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE, - G_TYPE_POINTER, - G_TYPE_POINTER); - - /** - * GdkWindow::from-embedder: - * @window: the offscreen window on which the signal is emitted - * @embedder_x: x coordinate in the embedder window - * @embedder_y: y coordinate in the embedder window - * @offscreen_x: (out) (type double): return location for the x - * coordinate in the offscreen window - * @offscreen_y: (out) (type double): return location for the y - * coordinate in the offscreen window - * - * The ::from-embedder signal is emitted to translate coordinates - * in the embedder of an offscreen window to the offscreen window. - * - * See also #GdkWindow::to-embedder. - * - * Since: 2.18 - */ - signals[FROM_EMBEDDER] = - g_signal_new (g_intern_static_string ("from-embedder"), - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowClass, from_embedder), - NULL, NULL, - _gdk_marshal_VOID__DOUBLE_DOUBLE_POINTER_POINTER, - G_TYPE_NONE, - 4, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE, - G_TYPE_POINTER, - G_TYPE_POINTER); - - /** - * GdkWindow::create-surface: - * @window: the offscreen window on which the signal is emitted - * @width: the width of the offscreen surface to create - * @height: the height of the offscreen surface to create - * - * The ::create-surface signal is emitted when an offscreen window - * needs its surface (re)created, which happens either when the - * window is first drawn to, or when the window is being - * resized. The first signal handler that returns a non-%NULL - * surface will stop any further signal emission, and its surface - * will be used. - * - * Note that it is not possible to access the window's previous - * surface from within any callback of this signal. Calling - * gdk_offscreen_window_get_surface() will lead to a crash. - * - * Returns: the newly created #cairo_surface_t for the offscreen window - * - * Since: 3.0 - */ - signals[CREATE_SURFACE] = - g_signal_new (g_intern_static_string ("create-surface"), - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowClass, create_surface), - create_surface_accumulator, NULL, - _gdk_marshal_BOXED__INT_INT, - CAIRO_GOBJECT_TYPE_SURFACE, - 2, - G_TYPE_INT, - G_TYPE_INT); - /** * GdkWindow::moved-to-rect: * @window: the #GdkWindow that moved @@ -618,12 +444,6 @@ gdk_window_get_property (GObject *object, } } -static gboolean -gdk_window_is_offscreen (GdkWindow *window) -{ - return window->window_type == GDK_WINDOW_OFFSCREEN; -} - static GdkWindow * gdk_window_get_impl_window (GdkWindow *window) { @@ -691,11 +511,6 @@ remove_sibling_overlapped_area (GdkWindow *window, if (!GDK_WINDOW_IS_MAPPED (sibling) || sibling->input_only) continue; - /* Ignore offscreen children, as they don't draw in their parent and - * don't take part in the clipping */ - if (gdk_window_is_offscreen (sibling)) - continue; - r.x = sibling->x; r.y = sibling->y; r.width = sibling->width; @@ -753,11 +568,6 @@ remove_child_area (GdkWindow *window, if (!GDK_WINDOW_IS_MAPPED (child) || child->input_only) continue; - /* Ignore offscreen children, as they don't draw in their parent and - * don't take part in the clipping */ - if (gdk_window_is_offscreen (child)) - continue; - r.x = child->x; r.y = child->y; r.width = child->width; @@ -869,9 +679,7 @@ should_apply_clip_as_shape (GdkWindow *window) { return gdk_window_has_impl (window) && - /* Not for offscreens */ - !gdk_window_is_offscreen (window) && - /* or for non-shaped toplevels */ + /* Not for non-shaped toplevels */ (!gdk_window_is_toplevel (window) || window->shape != NULL || window->applied_shape) && /* or for foreign windows */ @@ -1388,7 +1196,6 @@ gdk_window_new (GdkWindow *parent, { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: - case GDK_WINDOW_OFFSCREEN: if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT) g_warning (G_STRLOC "Toplevel windows must be created as children of\n" "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN"); @@ -1439,12 +1246,7 @@ gdk_window_new (GdkWindow *parent, if (window->parent->window_type == GDK_WINDOW_ROOT) native = TRUE; /* Always use native windows for toplevels */ - if (gdk_window_is_offscreen (window)) - { - _gdk_offscreen_window_new (window, attributes, attributes_mask); - window->impl_window = window; - } - else if (native) + if (native) { event_mask = get_native_event_mask (window); @@ -1748,7 +1550,6 @@ gdk_window_reparent (GdkWindow *window, else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL; break; - case GDK_WINDOW_OFFSCREEN: case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_CHILD: case GDK_WINDOW_TEMP: @@ -1823,8 +1624,6 @@ gdk_window_reparent (GdkWindow *window, * Tries to ensure that there is a window-system native window for this * GdkWindow. This may fail in some situations, returning %FALSE. * - * Offscreen window and children of them can never have native windows. - * * Some backends may not support native child windows. * * Returns: %TRUE if the window has a native window, %FALSE otherwise @@ -1850,11 +1649,8 @@ gdk_window_ensure_native (GdkWindow *window) impl_window = gdk_window_get_impl_window (window); - if (gdk_window_is_offscreen (impl_window)) - return FALSE; /* native in offscreens not supported */ - if (impl_window == window) - /* Already has an impl, and its not offscreen . */ + /* Already has an impl. */ return TRUE; /* Need to create a native window */ @@ -2056,7 +1852,6 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, case GDK_WINDOW_CHILD: case GDK_WINDOW_TEMP: case GDK_WINDOW_FOREIGN: - case GDK_WINDOW_OFFSCREEN: if (window->window_type == GDK_WINDOW_FOREIGN && !foreign_destroy) { /* Logically, it probably makes more sense to send @@ -2331,30 +2126,6 @@ gdk_window_is_destroyed (GdkWindow *window) return GDK_WINDOW_DESTROYED (window); } -static void -to_embedder (GdkWindow *window, - gdouble offscreen_x, - gdouble offscreen_y, - gdouble *embedder_x, - gdouble *embedder_y) -{ - g_signal_emit (window, signals[TO_EMBEDDER], 0, - offscreen_x, offscreen_y, - embedder_x, embedder_y); -} - -static void -from_embedder (GdkWindow *window, - gdouble embedder_x, - gdouble embedder_y, - gdouble *offscreen_x, - gdouble *offscreen_y) -{ - g_signal_emit (window, signals[FROM_EMBEDDER], 0, - embedder_x, embedder_y, - offscreen_x, offscreen_y); -} - /** * gdk_window_has_native: * @window: a #GdkWindow @@ -2413,11 +2184,6 @@ gdk_window_get_position (GdkWindow *window, * matter for toplevel windows, because the window manager may choose * to reparent them. * - * Note that you should use gdk_window_get_effective_parent() when - * writing generic code that walks up a window hierarchy, because - * gdk_window_get_parent() will most likely not do what you expect if - * there are offscreen windows in the hierarchy. - * * Returns: (transfer none): parent of @window **/ GdkWindow* @@ -2428,31 +2194,6 @@ gdk_window_get_parent (GdkWindow *window) return window->parent; } -/** - * gdk_window_get_effective_parent: - * @window: a #GdkWindow - * - * Obtains the parent of @window, as known to GDK. Works like - * gdk_window_get_parent() for normal windows, but returns the - * window’s embedder for offscreen windows. - * - * See also: gdk_offscreen_window_get_embedder() - * - * Returns: (transfer none): effective parent of @window - * - * Since: 2.22 - **/ -GdkWindow * -gdk_window_get_effective_parent (GdkWindow *window) -{ - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - - if (gdk_window_is_offscreen (window)) - return gdk_offscreen_window_get_embedder (window); - else - return window->parent; -} - /** * gdk_window_get_toplevel: * @window: a #GdkWindow @@ -2463,11 +2204,6 @@ gdk_window_get_effective_parent (GdkWindow *window) * toplevel window, as is a %GDK_WINDOW_CHILD window that * has a root window as parent. * - * Note that you should use gdk_window_get_effective_toplevel() when - * you want to get to a window’s toplevel as seen on screen, because - * gdk_window_get_toplevel() will most likely not do what you expect - * if there are offscreen windows in the hierarchy. - * * Returns: (transfer none): the toplevel window containing @window **/ GdkWindow * @@ -2485,35 +2221,6 @@ gdk_window_get_toplevel (GdkWindow *window) return window; } -/** - * gdk_window_get_effective_toplevel: - * @window: a #GdkWindow - * - * Gets the toplevel window that’s an ancestor of @window. - * - * Works like gdk_window_get_toplevel(), but treats an offscreen window's - * embedder as its parent, using gdk_window_get_effective_parent(). - * - * See also: gdk_offscreen_window_get_embedder() - * - * Returns: (transfer none): the effective toplevel window containing @window - * - * Since: 2.22 - **/ -GdkWindow * -gdk_window_get_effective_toplevel (GdkWindow *window) -{ - GdkWindow *parent; - - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - - while ((parent = gdk_window_get_effective_parent (window)) != NULL && - (gdk_window_get_window_type (parent) != GDK_WINDOW_ROOT)) - window = parent; - - return window; -} - /** * gdk_window_get_children: * @window: a #GdkWindow @@ -3622,26 +3329,6 @@ gdk_window_schedule_update (GdkWindow *window) GDK_FRAME_CLOCK_PHASE_PAINT); } -static void -gdk_window_add_damage (GdkWindow *toplevel, - cairo_region_t *damaged_region) -{ - GdkDisplay *display; - GdkEvent event = { 0, }; - - /* This function only makes sense for offscreen windows. */ - g_assert (gdk_window_is_offscreen (toplevel)); - - event.expose.type = GDK_DAMAGE; - event.expose.window = toplevel; - event.expose.send_event = FALSE; - event.expose.region = damaged_region; - cairo_region_get_extents (event.expose.region, &event.expose.area); - - display = gdk_window_get_display (event.expose.window); - _gdk_event_queue_append (display, gdk_event_copy (&event)); -} - static void _gdk_window_process_updates_recurse_helper (GdkWindow *window, cairo_region_t *expose_region) @@ -3670,9 +3357,6 @@ _gdk_window_process_updates_recurse_helper (GdkWindow *window, if (cairo_region_is_empty (clipped_expose_region)) goto out; - if (gdk_window_is_offscreen (window)) - gdk_window_add_damage (window, clipped_expose_region); - /* Paint the window before the children, clipped to the window region */ /* While gtk+ no longer handles exposes on anything but native @@ -3717,11 +3401,6 @@ _gdk_window_process_updates_recurse_helper (GdkWindow *window, if (child->destroyed || !GDK_WINDOW_IS_MAPPED (child) || child->input_only) continue; - /* Ignore offscreen children, as they don't draw in their parent and - * don't take part in the clipping */ - if (gdk_window_is_offscreen (child)) - continue; - /* Client side child, expose */ if (child->impl == window->impl) { @@ -5625,18 +5304,6 @@ gdk_window_set_device_events (GdkWindow *window, native = gdk_window_get_toplevel (window); - while (gdk_window_is_offscreen (native)) - { - native = gdk_offscreen_window_get_embedder (native); - - if (native == NULL || - (!_gdk_window_has_impl (native) && - !gdk_window_is_viewable (native))) - return; - - native = gdk_window_get_toplevel (native); - } - device_mask = get_native_device_event_mask (window, device); GDK_DEVICE_GET_CLASS (device)->select_window_events (device, native, device_mask); } @@ -6461,19 +6128,8 @@ gdk_window_get_root_coords (GdkWindow *window, * in parent’s coordinate system, or %NULL * * Transforms window coordinates from a child window to its parent - * window, where the parent window is the normal parent as returned by - * gdk_window_get_parent() for normal windows, and the window's - * embedder as returned by gdk_offscreen_window_get_embedder() for - * offscreen windows. - * - * For normal windows, calling this function is equivalent to adding - * the return values of gdk_window_get_position() to the child coordinates. - * For offscreen windows however (which can be arbitrarily transformed), - * this function calls the GdkWindow::to-embedder: signal to translate - * the coordinates. - * - * You should always use this function when writing generic code that - * walks up a window hierarchy. + * window. Calling this function is equivalent to adding the return + * values of gdk_window_get_position() to the child coordinates. * * See also: gdk_window_coords_from_parent() * @@ -6488,26 +6144,11 @@ gdk_window_coords_to_parent (GdkWindow *window, { g_return_if_fail (GDK_IS_WINDOW (window)); - if (gdk_window_is_offscreen (window)) - { - gdouble px, py; - - to_embedder (window, x, y, &px, &py); + if (parent_x) + *parent_x = x + window->x; - if (parent_x) - *parent_x = px; - - if (parent_y) - *parent_y = py; - } - else - { - if (parent_x) - *parent_x = x + window->x; - - if (parent_y) - *parent_y = y + window->y; - } + if (parent_y) + *parent_y = y + window->y; } /** @@ -6519,19 +6160,10 @@ gdk_window_coords_to_parent (GdkWindow *window, * @y: (out) (allow-none): return location for Y coordinate in child’s coordinate system * * Transforms window coordinates from a parent window to a child - * window, where the parent window is the normal parent as returned by - * gdk_window_get_parent() for normal windows, and the window's - * embedder as returned by gdk_offscreen_window_get_embedder() for - * offscreen windows. - * - * For normal windows, calling this function is equivalent to subtracting - * the return values of gdk_window_get_position() from the parent coordinates. - * For offscreen windows however (which can be arbitrarily transformed), - * this function calls the GdkWindow::from-embedder: signal to translate - * the coordinates. + * window. * - * You should always use this function when writing generic code that - * walks down a window hierarchy. + * Calling this function is equivalent to subtracting the return + * values of gdk_window_get_position() from the parent coordinates. * * See also: gdk_window_coords_to_parent() * @@ -6546,26 +6178,11 @@ gdk_window_coords_from_parent (GdkWindow *window, { g_return_if_fail (GDK_IS_WINDOW (window)); - if (gdk_window_is_offscreen (window)) - { - gdouble cx, cy; - - from_embedder (window, parent_x, parent_y, &cx, &cy); - - if (x) - *x = cx; - - if (y) - *y = cy; - } - else - { - if (x) - *x = parent_x - window->x; + if (x) + *x = parent_x - window->x; - if (y) - *y = parent_y - window->y; - } + if (y) + *y = parent_y - window->y; } /** @@ -6999,17 +6616,6 @@ gdk_window_is_shaped (GdkWindow *window) return window->shaped; } -/* Gets the toplevel for a window as used for events, - i.e. including offscreen parents */ -static GdkWindow * -get_event_parent (GdkWindow *window) -{ - if (gdk_window_is_offscreen (window)) - return gdk_offscreen_window_get_embedder ((GdkWindow *)window); - else - return window->parent; -} - /* Gets the toplevel for a window as used for events, i.e. including offscreen parents going up to the native toplevel */ @@ -7018,7 +6624,7 @@ get_event_toplevel (GdkWindow *window) { GdkWindow *parent; - while ((parent = get_event_parent (window)) != NULL && + while ((parent = window->parent) != NULL && (parent->window_type != GDK_WINDOW_ROOT)) window = parent; @@ -7037,7 +6643,7 @@ _gdk_window_event_parent_of (GdkWindow *parent, if (w == parent) return TRUE; - w = get_event_parent (w); + w = w->parent; } return FALSE; @@ -7078,7 +6684,7 @@ update_cursor (GdkDisplay *display, the cursor is inherited from the parent */ while (cursor_window->cursor == NULL && !g_hash_table_contains (cursor_window->device_cursor, device) && - (parent = get_event_parent (cursor_window)) != NULL && + (parent = cursor_window->parent) != NULL && parent->window_type != GDK_WINDOW_ROOT) cursor_window = parent; @@ -7207,7 +6813,7 @@ convert_toplevel_coords_to_window (GdkWindow *window, y = toplevel_y; children = NULL; - while ((parent = get_event_parent (window)) != NULL && + while ((parent = window->parent) != NULL && (parent->window_type != GDK_WINDOW_ROOT)) { children = g_list_prepend (children, window); @@ -7223,21 +6829,6 @@ convert_toplevel_coords_to_window (GdkWindow *window, *window_y = y; } -static GdkWindow * -pick_embedded_child (GdkWindow *window, - gdouble x, - gdouble y) -{ - GdkWindow *res; - - res = NULL; - g_signal_emit (window, - signals[PICK_EMBEDDED_CHILD], 0, - x, y, &res); - - return res; -} - GdkWindow * _gdk_window_find_child_at (GdkWindow *window, double x, @@ -7264,14 +6855,6 @@ _gdk_window_find_child_at (GdkWindow *window, NULL, NULL, NULL)) return (GdkWindow *)sub; } - - if (window->num_offscreen_children > 0) - { - sub = pick_embedded_child (window, - x, y); - if (sub) - return (GdkWindow *)sub; - } } return NULL; @@ -7315,18 +6898,6 @@ _gdk_window_find_descendant_at (GdkWindow *window, break; } } - if (!found && - window->num_offscreen_children > 0) - { - sub = pick_embedded_child (window, - x, y); - if (sub) - { - found = TRUE; - window = sub; - from_embedder (sub, x, y, &x, &y); - } - } } while (found); } @@ -7552,14 +7123,14 @@ find_common_ancestor (GdkWindow *win1, while (tmp != NULL && tmp->window_type != GDK_WINDOW_ROOT) { path1 = g_list_prepend (path1, tmp); - tmp = get_event_parent (tmp); + tmp = tmp->parent; } tmp = win2; while (tmp != NULL && tmp->window_type != GDK_WINDOW_ROOT) { path2 = g_list_prepend (path2, tmp); - tmp = get_event_parent (tmp); + tmp = tmp->parent; } list1 = path1; @@ -7896,7 +7467,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, notify_type = GDK_NOTIFY_VIRTUAL; last = a; - win = get_event_parent (a); + win = a->parent; while (win != c && win->window_type != GDK_WINDOW_ROOT) { send_crossing_event (display, toplevel, @@ -7911,7 +7482,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, serial); last = win; - win = get_event_parent (win); + win = win->parent; } } } @@ -7924,11 +7495,11 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, if (c != b) { path = NULL; - win = get_event_parent (b); + win = b->parent; while (win != c && win->window_type != GDK_WINDOW_ROOT) { path = g_list_prepend (path, win); - win = get_event_parent (win); + win = win->parent; } if (non_linear) @@ -8039,22 +7610,6 @@ _gdk_display_set_window_under_pointer (GdkDisplay *display, _gdk_display_enable_motion_hints (display, device); } -/** - * gdk_window_geometry_changed: - * @window: an embedded offscreen #GdkWindow - * - * This function informs GDK that the geometry of an embedded - * offscreen window has changed. This is necessary for GDK to keep - * track of which offscreen window the pointer is in. - * - * Since: 2.18 - */ -void -gdk_window_geometry_changed (GdkWindow *window) -{ - _gdk_synthesize_crossing_events_for_geometry_change (window); -} - static void source_events_device_added (GdkDeviceManager *device_manager, GdkDevice *device, @@ -8366,7 +7921,7 @@ get_event_window (GdkDisplay *display, return pointer_window; } - pointer_window = get_event_parent (pointer_window); + pointer_window = pointer_window->parent; } if (grab != NULL && @@ -8738,7 +8293,7 @@ proxy_button_event (GdkEvent *source_event, /* Find the event window, that gets the grab */ w = pointer_window; while (w != NULL && - (parent = get_event_parent (w)) != NULL && + (parent = w->parent) != NULL && parent->window_type != GDK_WINDOW_ROOT) { if (w->event_mask & GDK_BUTTON_PRESS_MASK && @@ -9068,7 +8623,7 @@ gdk_window_print (GdkWindow *window, "dialog", "temp", "foreign", - "offscreen" + "subsurface" }; g_print ("%*s%p: [%s] %d,%d %dx%d", indent, "", window, diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index a6bc688197..9a887b7d57 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -67,8 +67,6 @@ typedef enum * @GDK_WINDOW_TEMP: override redirect temporary window (used to implement * #GtkMenu) * @GDK_WINDOW_FOREIGN: foreign window (see gdk_window_foreign_new()) - * @GDK_WINDOW_OFFSCREEN: offscreen window (see - * [Offscreen Windows][OFFSCREEN-WINDOWS]). Since 2.18 * @GDK_WINDOW_SUBSURFACE: subsurface-based window; This window is visually * tied to a toplevel, and is moved/stacked with it. Currently this window * type is only implemented in Wayland. Since 3.14 @@ -82,7 +80,6 @@ typedef enum GDK_WINDOW_CHILD, GDK_WINDOW_TEMP, GDK_WINDOW_FOREIGN, - GDK_WINDOW_OFFSCREEN, GDK_WINDOW_SUBSURFACE } GdkWindowType; @@ -460,25 +457,6 @@ struct _GdkWindowClass { GObjectClass parent_class; - GdkWindow * (* pick_embedded_child) (GdkWindow *window, - gdouble x, - gdouble y); - - /* the following 3 signals will only be emitted by offscreen windows */ - void (* to_embedder) (GdkWindow *window, - gdouble offscreen_x, - gdouble offscreen_y, - gdouble *embedder_x, - gdouble *embedder_y); - void (* from_embedder) (GdkWindow *window, - gdouble embedder_x, - gdouble embedder_y, - gdouble *offscreen_x, - gdouble *offscreen_y); - cairo_surface_t * (* create_surface) (GdkWindow *window, - gint width, - gint height); - /* Padding for future expansion */ void (*_gdk_reserved1) (void); void (*_gdk_reserved2) (void); @@ -829,11 +807,6 @@ GdkWindow * gdk_window_get_parent (GdkWindow *window); GDK_AVAILABLE_IN_ALL GdkWindow * gdk_window_get_toplevel (GdkWindow *window); -GDK_AVAILABLE_IN_ALL -GdkWindow * gdk_window_get_effective_parent (GdkWindow *window); -GDK_AVAILABLE_IN_ALL -GdkWindow * gdk_window_get_effective_toplevel (GdkWindow *window); - GDK_AVAILABLE_IN_ALL GList * gdk_window_get_children (GdkWindow *window); GDK_AVAILABLE_IN_ALL @@ -1025,18 +998,6 @@ void gdk_window_constrain_size (GdkGeometry *geometry, GDK_AVAILABLE_IN_ALL GdkWindow *gdk_get_default_root_window (void); -/* Offscreen redirection */ -GDK_AVAILABLE_IN_ALL -cairo_surface_t * - gdk_offscreen_window_get_surface (GdkWindow *window); -GDK_AVAILABLE_IN_ALL -void gdk_offscreen_window_set_embedder (GdkWindow *window, - GdkWindow *embedder); -GDK_AVAILABLE_IN_ALL -GdkWindow *gdk_offscreen_window_get_embedder (GdkWindow *window); -GDK_AVAILABLE_IN_ALL -void gdk_window_geometry_changed (GdkWindow *window); - /* Multidevice support */ GDK_AVAILABLE_IN_ALL void gdk_window_set_support_multidevice (GdkWindow *window, diff --git a/gdk/gdkwindowimpl.c b/gdk/gdkwindowimpl.c index c42c5aa218..af445e3bd6 100644 --- a/gdk/gdkwindowimpl.c +++ b/gdk/gdkwindowimpl.c @@ -184,7 +184,7 @@ traverse_to_toplevel (GdkWindow *window, gdouble xf = x; gdouble yf = y; - while ((parent = gdk_window_get_effective_parent (window)) != NULL && + while ((parent = window->parent) != NULL && (gdk_window_get_window_type (parent) != GDK_WINDOW_ROOT)) { gdk_window_coords_to_parent (window, xf, yf, &xf, &yf); diff --git a/gdk/makefile.msc b/gdk/makefile.msc index 0d88d1e417..ec5d6a9e27 100644 --- a/gdk/makefile.msc +++ b/gdk/makefile.msc @@ -77,7 +77,6 @@ gdk_OBJECTS = \ gdkkeys.obj \ gdkkeyuni.obj \ gdkmarshalers.obj \ - gdkoffscreenwindow.obj \ gdkpango.obj \ gdkpixbuf-drawable.obj \ gdkrectangle.obj \ diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c index 61d0b609b7..e4fc56a2a6 100644 --- a/gdk/mir/gdkmirwindowimpl.c +++ b/gdk/mir/gdkmirwindowimpl.c @@ -303,11 +303,11 @@ create_window_type_spec (GdkDisplay *display, { real_rect = *rect; - while (parent && !gdk_window_has_native (parent) && gdk_window_get_effective_parent (parent)) + while (parent && !gdk_window_has_native (parent) && gdk_window_get_parent (parent)) { real_rect.left += parent->x; real_rect.top += parent->y; - parent = gdk_window_get_effective_parent (parent); + parent = gdk_window_get_parent (parent); } } else diff --git a/gdk/quartz/gdkdevice-core-quartz.c b/gdk/quartz/gdkdevice-core-quartz.c index 6fc17aa7d1..6cb3b6da76 100644 --- a/gdk/quartz/gdkdevice-core-quartz.c +++ b/gdk/quartz/gdkdevice-core-quartz.c @@ -159,7 +159,7 @@ translate_coords_to_child_coords (GdkWindow *parent, *x -= tmp_x; *y -= tmp_y; - current = gdk_window_get_effective_parent (current); + current = gdk_window_get_parent (current); } } @@ -209,7 +209,7 @@ gdk_quartz_device_core_query_state_helper (GdkWindow *window, return NULL; } - toplevel = gdk_window_get_effective_toplevel (window); + toplevel = gdk_window_get_toplevel (window); if (mask) *mask = _gdk_quartz_events_get_current_keyboard_modifiers () | diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c index d43695da12..f8fdaf526b 100644 --- a/gdk/quartz/gdkevents-quartz.c +++ b/gdk/quartz/gdkevents-quartz.c @@ -42,8 +42,7 @@ #define WINDOW_IS_TOPLEVEL(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) /* This is the window corresponding to the key window */ static GdkWindow *current_keyboard_window; @@ -672,7 +671,7 @@ find_toplevel_for_keyboard_event (NSEvent *nsevent) grab = _gdk_display_get_last_device_grab (display, device); if (grab && grab->window && !grab->owner_events) { - window = gdk_window_get_effective_toplevel (grab->window); + window = gdk_window_get_toplevel (grab->window); break; } } @@ -746,7 +745,7 @@ find_toplevel_for_mouse_event (NSEvent *nsevent, /* Finally check the grab window. */ GdkWindow *grab_toplevel; - grab_toplevel = gdk_window_get_effective_toplevel (grab->window); + grab_toplevel = gdk_window_get_toplevel (grab->window); get_window_point_from_screen_point (grab_toplevel, screen_point, x, y); diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c index df645e6cda..13b0274e64 100644 --- a/gdk/quartz/gdkscreen-quartz.c +++ b/gdk/quartz/gdkscreen-quartz.c @@ -203,11 +203,7 @@ _gdk_quartz_screen_update_window_sizes (GdkScreen *screen) windows = gdk_screen_get_toplevel_windows (screen); for (list = windows; list; list = list->next) - { - if (GDK_WINDOW_TYPE(list->data) == GDK_WINDOW_OFFSCREEN) - continue; - _gdk_quartz_window_update_position (list->data); - } + _gdk_quartz_window_update_position (list->data); g_list_free (windows); } diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index e07f7b61c2..f15fbd0e28 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -64,8 +64,7 @@ static void clear_toplevel_order (void); #define WINDOW_IS_TOPLEVEL(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) /* * GdkQuartzWindow @@ -386,7 +385,7 @@ _gdk_quartz_window_process_updates_recurse (GdkWindow *window, { GdkWindow *toplevel; - toplevel = gdk_window_get_effective_toplevel (window); + toplevel = gdk_window_get_toplevel (window); if (toplevel && WINDOW_IS_TOPLEVEL (toplevel)) { GdkWindowImplQuartz *toplevel_impl; @@ -2284,7 +2283,7 @@ gdk_quartz_window_get_frame_extents (GdkWindow *window, rect->width = 1; rect->height = 1; - toplevel = gdk_window_get_effective_toplevel (window); + toplevel = gdk_window_get_toplevel (window); impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl); ns_rect = [impl->toplevel frame]; diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index f139b77cae..ce4915bea1 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -4620,18 +4620,6 @@ gdk_wayland_seat_grab (GdkSeat *seat, native = gdk_window_get_toplevel (window); - while (native->window_type == GDK_WINDOW_OFFSCREEN) - { - native = gdk_offscreen_window_get_embedder (native); - - if (native == NULL || - (!_gdk_window_has_impl (native) && - !gdk_window_is_viewable (native))) - return GDK_GRAB_NOT_VIEWABLE; - - native = gdk_window_get_toplevel (native); - } - if (native == NULL || GDK_WINDOW_DESTROYED (native)) return GDK_GRAB_NOT_VIEWABLE; diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index f6b4b7bc8e..a714b18ac4 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -48,13 +48,11 @@ enum { static guint signals[LAST_SIGNAL]; #define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \ - (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD) #define WINDOW_IS_TOPLEVEL(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) #define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */ @@ -1619,11 +1617,11 @@ get_real_parent_and_translate (GdkWindow *window, while (parent && !gdk_window_has_native (parent) && - gdk_window_get_effective_parent (parent)) + gdk_window_get_parent (parent)) { *x += parent->x; *y += parent->y; - parent = gdk_window_get_effective_parent (parent); + parent = gdk_window_get_parent (parent); } return parent; @@ -2296,7 +2294,7 @@ gdk_wayland_window_map (GdkWindow *window) } if (transient_for) - transient_for = get_popup_parent (gdk_window_get_effective_toplevel (transient_for)); + transient_for = get_popup_parent (gdk_window_get_toplevel (transient_for)); /* If the position was not explicitly set, start the popup at the * position of the device that holds the grab. @@ -2307,7 +2305,7 @@ gdk_wayland_window_map (GdkWindow *window) } else { - transient_for = gdk_window_get_effective_toplevel (impl->transient_for); + transient_for = gdk_window_get_toplevel (impl->transient_for); transient_for = get_popup_parent (transient_for); } diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index cec3dcc763..f1e9ef5451 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -2379,9 +2379,6 @@ _gdk_win32_window_register_dnd (GdkWindow *window) g_return_if_fail (window != NULL); - if (gdk_window_get_window_type (window) == GDK_WINDOW_OFFSCREEN) - return; - if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL) return; else diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 6cc0b0efaf..12d57c16ea 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -132,8 +132,7 @@ static void _gdk_win32_impl_release_dc (GdkWindowImplWin32 *impl); #define WINDOW_IS_TOPLEVEL(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) + GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) GdkScreen * GDK_WINDOW_SCREEN (GObject *win) diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h index 48100dc052..f53db8ceb3 100644 --- a/gdk/x11/gdkdisplay-x11.h +++ b/gdk/x11/gdkdisplay-x11.h @@ -119,9 +119,6 @@ struct _GdkX11Display guint have_input_shapes : 1; gint shape_event_base; - /* The offscreen window that has the pointer in it (if any) */ - GdkWindow *active_offscreen_window; - GSList *error_traps; gint wm_moveresize_button; diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index b28407e5a4..89460744d1 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -2496,9 +2496,6 @@ _gdk_x11_window_register_dnd (GdkWindow *window) g_return_if_fail (window != NULL); - if (gdk_window_get_window_type (window) == GDK_WINDOW_OFFSCREEN) - return; - base_precache_atoms (display); if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 5744d66029..761bedbfe8 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -1925,9 +1925,6 @@ _gdk_x11_window_set_window_scale (GdkWindow *window, GdkToplevelX11 *toplevel; GdkWindowHints geom_mask; - if (window->window_type == GDK_WINDOW_OFFSCREEN) - return; - impl = GDK_WINDOW_IMPL_X11 (window->impl); impl->window_scale = scale; diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8277b3339c..356523fb24 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -250,7 +250,6 @@ gtk_public_h_sources = \ gtkmountoperation.h \ gtknativedialog.h \ gtknotebook.h \ - gtkoffscreenwindow.h \ gtkorientable.h \ gtkoverlay.h \ gtkpadcontroller.h \ @@ -820,7 +819,6 @@ gtk_base_c_sources = \ gtkmountoperation.c \ gtknativedialog.c \ gtknotebook.c \ - gtkoffscreenwindow.c \ gtkorientable.c \ gtkoverlay.c \ gtkpadcontroller.c \ diff --git a/gtk/gtk-autocleanups.h b/gtk/gtk-autocleanups.h index ea47ba08c8..9ea63c6c9b 100644 --- a/gtk/gtk-autocleanups.h +++ b/gtk/gtk-autocleanups.h @@ -116,7 +116,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMenuToolButton, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMessageDialog, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMountOperation, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkNotebook, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkOffscreenWindow, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkOrientable, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkOverlay, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPageSetup, g_object_unref) diff --git a/gtk/gtk.h b/gtk/gtk.h index 598f04f064..5bc0b540ea 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -149,7 +149,6 @@ #include #include #include -#include #include #include #include diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c index a8fd26a07d..240b107e1b 100644 --- a/gtk/gtkdnd-quartz.c +++ b/gtk/gtkdnd-quartz.c @@ -1145,7 +1145,7 @@ gtk_drag_begin_internal (GtkWidget *widget, * nswindow. Then, we convert to the NSWindow coordinate system. */ window = event->any.window; - GdkWindow *toplevel = gdk_window_get_effective_toplevel (window); + GdkWindow *toplevel = gdk_window_get_toplevel (window); while (window != toplevel) { @@ -1154,7 +1154,7 @@ gtk_drag_begin_internal (GtkWidget *widget, gdk_window_coords_to_parent (window, old_x, old_y, &dx, &dy); - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); } } time = (double)gdk_event_get_time (event); diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index 22c56d3589..1866a6937a 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -2937,7 +2937,7 @@ gtk_flow_box_motion_notify_event (GtkWidget *widget, &parent_x, &parent_y); relative_x = parent_x; relative_y = parent_y; - event_window = gdk_window_get_effective_parent (event_window); + event_window = gdk_window_get_parent (event_window); } child = gtk_flow_box_find_child_at_pos (box, relative_x, relative_y); diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index 8f92f1d69c..3d755101c6 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -408,7 +408,7 @@ _find_widget_window (GtkGesture *gesture, gtk_widget_get_window (widget) == window) return window; - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); } return NULL; @@ -488,7 +488,7 @@ _update_widget_coordinates (GtkGesture *gesture, gdk_window_get_position (window, &wx, &wy); event_x += wx; event_y += wy; - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); } if (!window) @@ -690,7 +690,7 @@ gesture_within_window (GtkGesture *gesture, if (window == parent) return TRUE; - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); } return FALSE; diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 90ebaca6d9..3bc32572bd 100644 --- a/gtk/gtklistbox.c +++ b/gtk/gtklistbox.c @@ -1871,7 +1871,7 @@ gtk_list_box_motion_notify_event (GtkWidget *widget, { gdk_window_coords_to_parent (event_window, 0, relative_y, NULL, &parent_y); relative_y = parent_y; - event_window = gdk_window_get_effective_parent (event_window); + event_window = gdk_window_get_parent (event_window); } row = gtk_list_box_get_row_at_y (box, relative_y); diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c deleted file mode 100644 index 1c6204c27f..0000000000 --- a/gtk/gtkoffscreenwindow.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - * Authors: Cody Russell - * Alexander Larsson - */ - -#include "config.h" - -#include "gtkoffscreenwindow.h" -#include "gtkwidgetprivate.h" -#include "gtkcontainerprivate.h" -#include "gtkprivate.h" - -/** - * SECTION:gtkoffscreenwindow - * @short_description: A toplevel to manage offscreen rendering of child widgets - * @title: GtkOffscreenWindow - * - * GtkOffscreenWindow is strictly intended to be used for obtaining - * snapshots of widgets that are not part of a normal widget hierarchy. - * Since #GtkOffscreenWindow is a toplevel widget you cannot obtain - * snapshots of a full window with it since you cannot pack a toplevel - * widget in another toplevel. - * - * The idea is to take a widget and manually set the state of it, - * add it to a GtkOffscreenWindow and then retrieve the snapshot - * as a #cairo_surface_t or #GdkPixbuf. - * - * GtkOffscreenWindow derives from #GtkWindow only as an implementation - * detail. Applications should not use any API specific to #GtkWindow - * to operate on this object. It should be treated as a #GtkBin that - * has no parent widget. - * - * When contained offscreen widgets are redrawn, GtkOffscreenWindow - * will emit a #GtkWidget::damage-event signal. - */ - -G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW); - -static void -gtk_offscreen_window_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child = gtk_bin_get_child (bin); - int default_size; - - *minimum = 0; - *natural = 0; - - if (child != NULL && gtk_widget_get_visible (child)) - { - int child_min, child_nat; - - gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL); - *minimum += child_min; - *natural += child_nat; - } - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_window_get_default_size (GTK_WINDOW (widget), &default_size, NULL); - else - gtk_window_get_default_size (GTK_WINDOW (widget), NULL, &default_size); - - *minimum = MAX (*minimum, default_size); - *natural = MAX (*natural, default_size); -} - -static void -gtk_offscreen_window_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child; - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, - allocation->y, - allocation->width, - allocation->height); - - child = gtk_bin_get_child (bin); - - if (child != NULL && gtk_widget_get_visible (child)) - { - GtkAllocation child_alloc; - - child_alloc.x = 0; - child_alloc.y = 0; - child_alloc.width = allocation->width; - child_alloc.height = allocation->height; - - gtk_widget_size_allocate (child, &child_alloc); - } - - gtk_widget_queue_draw (widget); -} - -static void -gtk_offscreen_window_realize (GtkWidget *widget) -{ - GtkAllocation allocation; - GtkBin *bin; - GtkWidget *child; - GdkWindow *window; - GdkWindowAttr attributes; - gint attributes_mask; - - bin = GTK_BIN (widget); - - gtk_widget_set_realized (widget, TRUE); - - gtk_widget_get_allocation (widget, &allocation); - - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_OFFSCREEN; - attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - attributes.wclass = GDK_INPUT_OUTPUT; - - attributes_mask = GDK_WA_X | GDK_WA_Y; - - window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, window); - gtk_widget_register_window (widget, window); - - child = gtk_bin_get_child (bin); - if (child) - gtk_widget_set_parent_window (child, window); -} - -static void -gtk_offscreen_window_resize (GtkWidget *widget) -{ - GtkAllocation allocation = { 0, 0 }; - GtkRequisition requisition; - - gtk_widget_get_preferred_size (widget, &requisition, NULL); - - allocation.width = requisition.width; - allocation.height = requisition.height; - gtk_widget_size_allocate (widget, &allocation); -} - -static void -move_focus (GtkWidget *widget, - GtkDirectionType dir) -{ - gtk_widget_child_focus (widget, dir); - - if (!gtk_container_get_focus_child (GTK_CONTAINER (widget))) - gtk_window_set_focus (GTK_WINDOW (widget), NULL); -} - -static void -gtk_offscreen_window_show (GtkWidget *widget) -{ - gboolean need_resize; - - _gtk_widget_set_visible_flag (widget, TRUE); - - need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget); - - if (need_resize) - gtk_offscreen_window_resize (widget); - - gtk_widget_map (widget); - - /* Try to make sure that we have some focused widget */ - if (!gtk_window_get_focus (GTK_WINDOW (widget))) - move_focus (widget, GTK_DIR_TAB_FORWARD); -} - -static void -gtk_offscreen_window_hide (GtkWidget *widget) -{ - _gtk_widget_set_visible_flag (widget, FALSE); - gtk_widget_unmap (widget); -} - -static void -gtk_offscreen_window_check_resize (GtkContainer *container) -{ - GtkWidget *widget = GTK_WIDGET (container); - - if (gtk_widget_get_visible (widget)) - gtk_offscreen_window_resize (widget); -} - -static void -gtk_offscreen_window_class_init (GtkOffscreenWindowClass *class) -{ - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - widget_class = GTK_WIDGET_CLASS (class); - container_class = GTK_CONTAINER_CLASS (class); - - widget_class->realize = gtk_offscreen_window_realize; - widget_class->show = gtk_offscreen_window_show; - widget_class->hide = gtk_offscreen_window_hide; - widget_class->measure = gtk_offscreen_window_measure; - widget_class->size_allocate = gtk_offscreen_window_size_allocate; - - container_class->check_resize = gtk_offscreen_window_check_resize; -} - -static void -gtk_offscreen_window_init (GtkOffscreenWindow *window) -{ -} - -/* --- functions --- */ -/** - * gtk_offscreen_window_new: - * - * Creates a toplevel container widget that is used to retrieve - * snapshots of widgets without showing them on the screen. - * - * Returns: A pointer to a #GtkWidget - * - * Since: 2.20 - */ -GtkWidget * -gtk_offscreen_window_new (void) -{ - return g_object_new (gtk_offscreen_window_get_type (), NULL); -} - -/** - * gtk_offscreen_window_get_surface: - * @offscreen: the #GtkOffscreenWindow contained widget. - * - * Retrieves a snapshot of the contained widget in the form of - * a #cairo_surface_t. If you need to keep this around over window - * resizes then you should add a reference to it. - * - * Returns: (nullable) (transfer none): A #cairo_surface_t pointer to the offscreen - * surface, or %NULL. - * - * Since: 2.20 - */ -cairo_surface_t * -gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen) -{ - g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL); - - return gdk_offscreen_window_get_surface (gtk_widget_get_window (GTK_WIDGET (offscreen))); -} - -/** - * gtk_offscreen_window_get_pixbuf: - * @offscreen: the #GtkOffscreenWindow contained widget. - * - * Retrieves a snapshot of the contained widget in the form of - * a #GdkPixbuf. This is a new pixbuf with a reference count of 1, - * and the application should unreference it once it is no longer - * needed. - * - * Returns: (nullable) (transfer full): A #GdkPixbuf pointer, or %NULL. - * - * Since: 2.20 - */ -GdkPixbuf * -gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen) -{ - cairo_surface_t *surface; - GdkPixbuf *pixbuf = NULL; - GdkWindow *window; - - g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL); - - window = gtk_widget_get_window (GTK_WIDGET (offscreen)); - surface = gdk_offscreen_window_get_surface (window); - - if (surface != NULL) - { - pixbuf = gdk_pixbuf_get_from_surface (surface, - 0, 0, - gdk_window_get_width (window), - gdk_window_get_height (window)); - } - - return pixbuf; -} diff --git a/gtk/gtkoffscreenwindow.h b/gtk/gtkoffscreenwindow.h deleted file mode 100644 index 2434558986..0000000000 --- a/gtk/gtkoffscreenwindow.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - * Authors: Cody Russell - * Alexander Larsson - */ - -#ifndef __GTK_OFFSCREEN_WINDOW_H__ -#define __GTK_OFFSCREEN_WINDOW_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_OFFSCREEN_WINDOW (gtk_offscreen_window_get_type ()) -#define GTK_OFFSCREEN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindow)) -#define GTK_OFFSCREEN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindowClass)) -#define GTK_IS_OFFSCREEN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_OFFSCREEN_WINDOW)) -#define GTK_IS_OFFSCREEN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_OFFSCREEN_WINDOW)) -#define GTK_OFFSCREEN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindowClass)) - -typedef struct _GtkOffscreenWindow GtkOffscreenWindow; -typedef struct _GtkOffscreenWindowClass GtkOffscreenWindowClass; - -struct _GtkOffscreenWindow -{ - GtkWindow parent_object; -}; - -/** - * GtkOffscreenWindowClass: - * @parent_class: The parent class. - */ -struct _GtkOffscreenWindowClass -{ - GtkWindowClass parent_class; - - /*< private >*/ - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_offscreen_window_get_type (void) G_GNUC_CONST; - -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_offscreen_window_new (void); -GDK_AVAILABLE_IN_ALL -cairo_surface_t *gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen); -GDK_AVAILABLE_IN_ALL -GdkPixbuf *gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen); - -G_END_DECLS - -#endif /* __GTK_OFFSCREEN_WINDOW_H__ */ diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index c6724ccb54..c96b0ee7b1 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1130,7 +1130,7 @@ translate_to_widget (GtkWidget *widget, gdk_window_get_position (window, &wx, &wy); event_x += wx; event_y += wy; - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); } if (!gtk_widget_get_has_window (event_widget)) diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 4a2c76f94e..b722f9e1db 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -622,7 +622,7 @@ _gtk_widget_find_at_coords (GdkWindow *window, child_loc.x = px; child_loc.y = py; - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); } /* Failing to find widget->window can happen for e.g. a detached handle box; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 25f2193ae5..c070e1411d 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5743,7 +5743,7 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget, src_x = dx; src_y = dy; - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); if (!window) /* Handle GtkHandleBox */ return FALSE; @@ -5755,7 +5755,7 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget, { dest_list = g_list_prepend (dest_list, window); - window = gdk_window_get_effective_parent (window); + window = gdk_window_get_parent (window); if (!window) /* Handle GtkHandleBox */ { @@ -11215,7 +11215,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from, while (from_ancestor != NULL) { - from_ancestor = gdk_window_get_effective_parent (from_ancestor); + from_ancestor = gdk_window_get_parent (from_ancestor); if (from_ancestor == NULL) break; from_ancestors = g_list_prepend (from_ancestors, from_ancestor); @@ -11240,7 +11240,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from, while (to_ancestor != NULL) { - to_ancestor = gdk_window_get_effective_parent (to_ancestor); + to_ancestor = gdk_window_get_parent (to_ancestor); if (to_ancestor == NULL) break; to_ancestors = g_list_prepend (to_ancestors, to_ancestor); @@ -11269,7 +11269,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from, { if (from_ancestor != NULL) { - from_ancestor = gdk_window_get_effective_parent (from_ancestor); + from_ancestor = gdk_window_get_parent (from_ancestor); if (from_ancestor == to_window) break; if (from_ancestor) @@ -11277,7 +11277,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from, } if (to_ancestor != NULL) { - to_ancestor = gdk_window_get_effective_parent (to_ancestor); + to_ancestor = gdk_window_get_parent (to_ancestor); if (to_ancestor == from_window) break; if (to_ancestor) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 30ff7aa8bd..c95231e7c1 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6049,7 +6049,6 @@ gtk_window_map (GtkWidget *widget) gdk_window_show (gdk_window); if (!disable_startup_notification && - !GTK_IS_OFFSCREEN_WINDOW (window) && priv->type != GTK_WINDOW_POPUP) { /* Do we have a custom startup-notification id? */ diff --git a/gtk/makefile.msc.in b/gtk/makefile.msc.in index ad9934b2e7..a2b20359b8 100644 --- a/gtk/makefile.msc.in +++ b/gtk/makefile.msc.in @@ -251,7 +251,6 @@ gtk_OBJECTS = \ gtkmountoperation.obj \ gtkmountoperation-stub.obj \ gtknotebook.obj \ - gtkoffscreenwindow.obj \ gtkorientable.obj \ gtkpagesetup.obj \ gtkpaned.obj \ @@ -440,7 +439,6 @@ gtk_public_h_sources = \ gtkmodules.h \ gtkmountoperation.h \ gtknotebook.h \ - gtkoffscreenwindow.h \ gtkorientable.h \ gtkpagesetup.h \ gtkpaned.h \ diff --git a/tests/Makefile.am b/tests/Makefile.am index 5e7c99a769..cb17e2875e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,8 +98,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \ testmultidisplay \ testnotebookdnd \ testnouiprint \ - testoffscreen \ - testoffscreenwindow \ testorientable \ testoverlay \ testoverlaystyleclass \ @@ -224,8 +222,6 @@ testmountoperation_DEPENDENCIES = $(TEST_DEPS) testmultidisplay_DEPENDENCIES = $(TEST_DEPS) testnotebookdnd_DEPENDENCIES = $(TEST_DEPS) testnouiprint_DEPENDENCIES = $(TEST_DEPS) -testoffscreen_DEPENDENCIES = $(TEST_DEPS) -testoffscreenwindow_DEPENDENCIES = $(TEST_DEPS) testappchooser_DEPENDENCIES = $(TEST_DEPS) testappchooserbutton_DEPENDENCIES = $(TEST_DEPS) testorientable_DEPENDENCIES = $(TEST_DEPS) @@ -417,14 +413,6 @@ testcellarea_SOURCES = \ testtreemenu_SOURCES = \ testtreemenu.c -testoffscreen_SOURCES = \ - gtkoffscreenbox.c \ - gtkoffscreenbox.h \ - testoffscreen.c - -testoffscreenwindow_SOURCES = \ - testoffscreenwindow.c - testoverlay_SOURCES = \ testoverlay.c diff --git a/tests/gtkoffscreenbox.c b/tests/gtkoffscreenbox.c deleted file mode 100644 index ed456ebd8e..0000000000 --- a/tests/gtkoffscreenbox.c +++ /dev/null @@ -1,683 +0,0 @@ -/* - * gtkoffscreenbox.c - */ - -#include "config.h" - -#include -#include - -#include "gtkoffscreenbox.h" - -static void gtk_offscreen_box_realize (GtkWidget *widget); -static void gtk_offscreen_box_unrealize (GtkWidget *widget); -static void gtk_offscreen_box_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline); -static void gtk_offscreen_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean gtk_offscreen_box_damage (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_offscreen_box_draw (GtkWidget *widget, - cairo_t *cr); - -static void gtk_offscreen_box_add (GtkContainer *container, - GtkWidget *child); -static void gtk_offscreen_box_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_offscreen_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gtk_offscreen_box_child_type (GtkContainer *container); - -#define CHILD1_SIZE_SCALE 1.0 -#define CHILD2_SIZE_SCALE 1.0 - -G_DEFINE_TYPE (GtkOffscreenBox, gtk_offscreen_box, GTK_TYPE_CONTAINER); - -static void -to_child_2 (GtkOffscreenBox *offscreen_box, - double widget_x, double widget_y, - double *x_out, double *y_out) -{ - GtkAllocation child_area; - double x, y, xr, yr; - double cos_angle, sin_angle; - - x = widget_x; - y = widget_y; - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - gtk_widget_get_allocation (offscreen_box->child1, &child_area); - y -= child_area.height; - } - - gtk_widget_get_allocation (offscreen_box->child2, &child_area); - - x -= child_area.width / 2; - y -= child_area.height / 2; - - cos_angle = cos (-offscreen_box->angle); - sin_angle = sin (-offscreen_box->angle); - - xr = x * cos_angle - y * sin_angle; - yr = x * sin_angle + y * cos_angle; - x = xr; - y = yr; - - x += child_area.width / 2; - y += child_area.height / 2; - - *x_out = x; - *y_out = y; -} - -static void -to_parent_2 (GtkOffscreenBox *offscreen_box, - double offscreen_x, double offscreen_y, - double *x_out, double *y_out) -{ - GtkAllocation child_area; - double x, y, xr, yr; - double cos_angle, sin_angle; - - gtk_widget_get_allocation (offscreen_box->child2, &child_area); - - x = offscreen_x; - y = offscreen_y; - - x -= child_area.width / 2; - y -= child_area.height / 2; - - cos_angle = cos (offscreen_box->angle); - sin_angle = sin (offscreen_box->angle); - - xr = x * cos_angle - y * sin_angle; - yr = x * sin_angle + y * cos_angle; - x = xr; - y = yr; - - x += child_area.width / 2; - y += child_area.height / 2; - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - gtk_widget_get_allocation (offscreen_box->child1, &child_area); - y += child_area.height; - } - - *x_out = x; - *y_out = y; -} - -static void -gtk_offscreen_box_class_init (GtkOffscreenBoxClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - - widget_class->realize = gtk_offscreen_box_realize; - widget_class->unrealize = gtk_offscreen_box_unrealize; - widget_class->measure = gtk_offscreen_box_measure; - widget_class->size_allocate = gtk_offscreen_box_size_allocate; - widget_class->draw = gtk_offscreen_box_draw; - - g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET), - GTK_TYPE_OFFSCREEN_BOX, - g_cclosure_new (G_CALLBACK (gtk_offscreen_box_damage), - NULL, NULL)); - - container_class->add = gtk_offscreen_box_add; - container_class->remove = gtk_offscreen_box_remove; - container_class->forall = gtk_offscreen_box_forall; - container_class->child_type = gtk_offscreen_box_child_type; -} - -static void -gtk_offscreen_box_init (GtkOffscreenBox *offscreen_box) -{ - gtk_widget_set_has_window (GTK_WIDGET (offscreen_box), TRUE); -} - -GtkWidget * -gtk_offscreen_box_new (void) -{ - return g_object_new (GTK_TYPE_OFFSCREEN_BOX, NULL); -} - -static GdkWindow * -pick_offscreen_child (GdkWindow *offscreen_window, - double widget_x, double widget_y, - GtkOffscreenBox *offscreen_box) -{ - GtkAllocation child_area; - double x, y; - - /* First check for child 2 */ - if (offscreen_box->child2 && - gtk_widget_get_visible (offscreen_box->child2)) - { - to_child_2 (offscreen_box, - widget_x, widget_y, - &x, &y); - - gtk_widget_get_allocation (offscreen_box->child2, &child_area); - - if (x >= 0 && x < child_area.width && - y >= 0 && y < child_area.height) - return offscreen_box->offscreen_window2; - } - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - x = widget_x; - y = widget_y; - - gtk_widget_get_allocation (offscreen_box->child1, &child_area); - - if (x >= 0 && x < child_area.width && - y >= 0 && y < child_area.height) - return offscreen_box->offscreen_window1; - } - - return NULL; -} - -static void -offscreen_window_to_parent1 (GdkWindow *offscreen_window, - double offscreen_x, - double offscreen_y, - double *parent_x, - double *parent_y, - GtkOffscreenBox *offscreen_box) -{ - *parent_x = offscreen_x; - *parent_y = offscreen_y; -} - -static void -offscreen_window_from_parent1 (GdkWindow *window, - double parent_x, - double parent_y, - double *offscreen_x, - double *offscreen_y, - GtkOffscreenBox *offscreen_box) -{ - *offscreen_x = parent_x; - *offscreen_y = parent_y; -} - -static void -offscreen_window_to_parent2 (GdkWindow *offscreen_window, - double offscreen_x, - double offscreen_y, - double *parent_x, - double *parent_y, - GtkOffscreenBox *offscreen_box) -{ - to_parent_2 (offscreen_box, - offscreen_x, offscreen_y, - parent_x, parent_y); -} - -static void -offscreen_window_from_parent2 (GdkWindow *window, - double parent_x, - double parent_y, - double *offscreen_x, - double *offscreen_y, - GtkOffscreenBox *offscreen_box) -{ - to_child_2 (offscreen_box, - parent_x, parent_y, - offscreen_x, offscreen_y); -} - -static cairo_surface_t * -gdk_offscreen_box_create_alpha_image_surface (GdkWindow *offscreen, - gint width, - gint height) -{ - return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); -} - -static void -gtk_offscreen_box_realize (GtkWidget *widget) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); - GtkAllocation allocation, child_area; - GdkWindow *window; - GdkWindowAttr attributes; - gint attributes_mask; - GtkRequisition child_requisition; - int start_y = 0; - - gtk_widget_set_realized (widget, TRUE); - - gtk_widget_get_allocation (widget, &allocation); - - window = gdk_window_new_child (gtk_widget_get_parent_window (widget), - gtk_widget_get_events (widget) - | GDK_EXPOSURE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_SCROLL_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK, - &allocation); - gtk_widget_set_window (widget, window); - gdk_window_set_user_data (window, widget); - - g_signal_connect (window, "pick-embedded-child", - G_CALLBACK (pick_offscreen_child), offscreen_box); - - attributes.window_type = GDK_WINDOW_OFFSCREEN; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_EXPOSURE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_SCROLL_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y; - - /* Child 1 */ - attributes.x = attributes.y = 0; - attributes.width = allocation.width; - attributes.height = allocation.height; - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - gtk_widget_get_allocation (offscreen_box->child1, &child_area); - - attributes.width = child_area.width; - attributes.height = child_area.height; - start_y += child_area.height; - } - offscreen_box->offscreen_window1 = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), - &attributes, attributes_mask); - gdk_window_set_user_data (offscreen_box->offscreen_window1, widget); - if (offscreen_box->child1) - gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1); - - gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1, - window); - - g_signal_connect (offscreen_box->offscreen_window1, "to-embedder", - G_CALLBACK (offscreen_window_to_parent1), offscreen_box); - g_signal_connect (offscreen_box->offscreen_window1, "from-embedder", - G_CALLBACK (offscreen_window_from_parent1), offscreen_box); - - /* Child 2 */ - attributes.y = start_y; - child_requisition.width = child_requisition.height = 0; - if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) - { - gtk_widget_get_allocation (offscreen_box->child2, &child_area); - - attributes.width = child_area.width; - attributes.height = child_area.height; - } - offscreen_box->offscreen_window2 = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), - &attributes, attributes_mask); - gdk_window_set_user_data (offscreen_box->offscreen_window2, widget); - if (offscreen_box->child2) - gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2); - gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2, - window); - - g_signal_connect (offscreen_box->offscreen_window2, "create-surface", - G_CALLBACK (gdk_offscreen_box_create_alpha_image_surface), - offscreen_box); - g_signal_connect (offscreen_box->offscreen_window2, "to-embedder", - G_CALLBACK (offscreen_window_to_parent2), offscreen_box); - g_signal_connect (offscreen_box->offscreen_window2, "from-embedder", - G_CALLBACK (offscreen_window_from_parent2), offscreen_box); - - gdk_window_show (offscreen_box->offscreen_window1); - gdk_window_show (offscreen_box->offscreen_window2); -} - -static void -gtk_offscreen_box_unrealize (GtkWidget *widget) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); - - gdk_window_set_user_data (offscreen_box->offscreen_window1, NULL); - gdk_window_destroy (offscreen_box->offscreen_window1); - offscreen_box->offscreen_window1 = NULL; - - gdk_window_set_user_data (offscreen_box->offscreen_window2, NULL); - gdk_window_destroy (offscreen_box->offscreen_window2); - offscreen_box->offscreen_window2 = NULL; - - GTK_WIDGET_CLASS (gtk_offscreen_box_parent_class)->unrealize (widget); -} - -static GType -gtk_offscreen_box_child_type (GtkContainer *container) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container); - - if (offscreen_box->child1 && offscreen_box->child2) - return G_TYPE_NONE; - - return GTK_TYPE_WIDGET; -} - -static void -gtk_offscreen_box_add (GtkContainer *container, - GtkWidget *widget) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container); - - if (!offscreen_box->child1) - gtk_offscreen_box_add1 (offscreen_box, widget); - else if (!offscreen_box->child2) - gtk_offscreen_box_add2 (offscreen_box, widget); - else - g_warning ("GtkOffscreenBox cannot have more than 2 children"); -} - -void -gtk_offscreen_box_add1 (GtkOffscreenBox *offscreen_box, - GtkWidget *child) -{ - g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - if (offscreen_box->child1 == NULL) - { - gtk_widget_set_parent_window (child, offscreen_box->offscreen_window1); - gtk_widget_set_parent (child, GTK_WIDGET (offscreen_box)); - offscreen_box->child1 = child; - } -} - -void -gtk_offscreen_box_add2 (GtkOffscreenBox *offscreen_box, - GtkWidget *child) -{ - g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - if (offscreen_box->child2 == NULL) - { - gtk_widget_set_parent_window (child, offscreen_box->offscreen_window2); - gtk_widget_set_parent (child, GTK_WIDGET (offscreen_box)); - offscreen_box->child2 = child; - } -} - -static void -gtk_offscreen_box_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container); - gboolean was_visible; - - was_visible = gtk_widget_get_visible (widget); - - if (offscreen_box->child1 == widget) - { - gtk_widget_unparent (widget); - - offscreen_box->child1 = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else if (offscreen_box->child2 == widget) - { - gtk_widget_unparent (widget); - - offscreen_box->child2 = NULL; - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (container)); - } -} - -static void -gtk_offscreen_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container); - - g_return_if_fail (callback != NULL); - - if (offscreen_box->child1) - (*callback) (offscreen_box->child1, callback_data); - if (offscreen_box->child2) - (*callback) (offscreen_box->child2, callback_data); -} - -void -gtk_offscreen_box_set_angle (GtkOffscreenBox *offscreen_box, - gdouble angle) -{ - g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box)); - - offscreen_box->angle = angle; - gtk_widget_queue_draw (GTK_WIDGET (offscreen_box)); - - /* TODO: Really needs to resent pointer events if over the rotated window */ -} - - -static void -gtk_offscreen_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); - int w, h; - - w = 0; - h = 0; - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - GtkRequisition child_requisition; - - gtk_widget_get_preferred_size ( (offscreen_box->child1), - &child_requisition, NULL); - - w = MAX (w, CHILD1_SIZE_SCALE * child_requisition.width); - h += CHILD1_SIZE_SCALE * child_requisition.height; - } - - if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) - { - GtkRequisition child_requisition; - - gtk_widget_get_preferred_size ( (offscreen_box->child2), - &child_requisition, NULL); - - w = MAX (w, CHILD2_SIZE_SCALE * child_requisition.width); - h += CHILD2_SIZE_SCALE * child_requisition.height; - } - - requisition->width = w; - requisition->height = h; -} - - -static void -gtk_offscreen_box_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkRequisition requisition; - - gtk_offscreen_box_size_request (widget, &requisition); - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - *minimum = *natural = requisition.width; - else - *minimum = *natural = requisition.height; -} - -static void -gtk_offscreen_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkOffscreenBox *offscreen_box; - gint start_y; - - offscreen_box = GTK_OFFSCREEN_BOX (widget); - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, - allocation->y, - allocation->width, - allocation->height); - - start_y = 0; - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - GtkRequisition child_requisition; - GtkAllocation child_allocation; - - gtk_widget_get_preferred_size (offscreen_box->child1, - &child_requisition, NULL); - child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE - 1.0) / 2; - child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE - 1.0) / 2; - child_allocation.width = allocation->width; - child_allocation.height = child_requisition.height; - - start_y += CHILD1_SIZE_SCALE * child_requisition.height; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (offscreen_box->offscreen_window1, - child_allocation.x, - child_allocation.y, - child_allocation.width, - child_allocation.height); - - child_allocation.x = child_allocation.y = 0; - gtk_widget_size_allocate (offscreen_box->child1, &child_allocation); - } - - if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) - { - GtkRequisition child_requisition; - GtkAllocation child_allocation; - - gtk_widget_get_preferred_size (offscreen_box->child2, - &child_requisition, NULL); - child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE - 1.0) / 2; - child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE - 1.0) / 2; - child_allocation.width = allocation->width; - child_allocation.height = child_requisition.height; - - start_y += CHILD2_SIZE_SCALE * child_requisition.height; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (offscreen_box->offscreen_window2, - child_allocation.x, - child_allocation.y, - child_allocation.width, - child_allocation.height); - - child_allocation.x = child_allocation.y = 0; - gtk_widget_size_allocate (offscreen_box->child2, &child_allocation); - } -} - -static gboolean -gtk_offscreen_box_damage (GtkWidget *widget, - GdkEventExpose *event) -{ - gdk_window_invalidate_rect (gtk_widget_get_window (widget), - NULL, FALSE); - - return TRUE; -} - -static gboolean -gtk_offscreen_box_draw (GtkWidget *widget, - cairo_t *cr) -{ - GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); - GdkWindow *window; - - window = gtk_widget_get_window (widget); - if (gtk_cairo_should_draw_window (cr, window)) - { - cairo_surface_t *surface; - GtkAllocation child_area; - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window1); - - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - - gtk_widget_get_allocation (offscreen_box->child1, &child_area); - cairo_translate (cr, 0, child_area.height); - } - - if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) - { - surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window2); - - gtk_widget_get_allocation (offscreen_box->child2, &child_area); - - /* transform */ - cairo_translate (cr, child_area.width / 2, child_area.height / 2); - cairo_rotate (cr, offscreen_box->angle); - cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); - - /* paint */ - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - } - } - else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1)) - { - gtk_render_background (gtk_widget_get_style_context (widget), cr, - 0, 0, - - gdk_window_get_width (offscreen_box->offscreen_window1), - gdk_window_get_height (offscreen_box->offscreen_window1)); - - if (offscreen_box->child1) - gtk_container_propagate_draw (GTK_CONTAINER (widget), - offscreen_box->child1, - cr); - } - else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2)) - { - gtk_render_background (gtk_widget_get_style_context (widget), cr, - 0, 0, - gdk_window_get_width (offscreen_box->offscreen_window2), - gdk_window_get_height (offscreen_box->offscreen_window2)); - - if (offscreen_box->child2) - gtk_container_propagate_draw (GTK_CONTAINER (widget), - offscreen_box->child2, - cr); - } - - return FALSE; -} diff --git a/tests/gtkoffscreenbox.h b/tests/gtkoffscreenbox.h deleted file mode 100644 index aa1d15d775..0000000000 --- a/tests/gtkoffscreenbox.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __GTK_OFFSCREEN_BOX_H__ -#define __GTK_OFFSCREEN_BOX_H__ - - -#include -#include - - -G_BEGIN_DECLS - -#define GTK_TYPE_OFFSCREEN_BOX (gtk_offscreen_box_get_type ()) -#define GTK_OFFSCREEN_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_OFFSCREEN_BOX, GtkOffscreenBox)) -#define GTK_OFFSCREEN_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_OFFSCREEN_BOX, GtkOffscreenBoxClass)) -#define GTK_IS_OFFSCREEN_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_OFFSCREEN_BOX)) -#define GTK_IS_OFFSCREEN_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_OFFSCREEN_BOX)) -#define GTK_OFFSCREEN_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_OFFSCREEN_BOX, GtkOffscreenBoxClass)) - -typedef struct _GtkOffscreenBox GtkOffscreenBox; -typedef struct _GtkOffscreenBoxClass GtkOffscreenBoxClass; - -struct _GtkOffscreenBox -{ - GtkContainer container; - - GtkWidget *child1; - GtkWidget *child2; - - GdkWindow *offscreen_window1; - GdkWindow *offscreen_window2; - - gdouble angle; -}; - -struct _GtkOffscreenBoxClass -{ - GtkBinClass parent_class; -}; - -GType gtk_offscreen_box_get_type (void) G_GNUC_CONST; -GtkWidget* gtk_offscreen_box_new (void); -void gtk_offscreen_box_add1 (GtkOffscreenBox *offscreen, - GtkWidget *child); -void gtk_offscreen_box_add2 (GtkOffscreenBox *offscreen, - GtkWidget *child); -void gtk_offscreen_box_set_angle (GtkOffscreenBox *offscreen, - double angle); - - - -G_END_DECLS - -#endif /* __GTK_OFFSCREEN_BOX_H__ */ diff --git a/tests/makefile.msc b/tests/makefile.msc index 13b921a821..db93d672f2 100644 --- a/tests/makefile.msc +++ b/tests/makefile.msc @@ -50,7 +50,7 @@ TESTAPPS = \ testicontheme testiconview testimage testinput \ testmountoperation testmenubars testmerge testmultidisplay testmultiscreen \ testnouiprint testnotebookdnd \ - testoffscreen testorientable \ + testorientable \ testprint \ testrecentchooser testrecentchoosermenu testrichtext \ testscale testselection testspinbutton \ @@ -79,10 +79,6 @@ EXTRA_OBJETCS = prop-editor.obj EXTRA_LIBS = $(ATK_LIBS) !ENDIF -!IFDEF EXTRA_testoffscreen -EXTRA_OBJETCS = gtkoffscreenbox.obj -!ENDIF - !IFDEF EXTRA_testprint EXTRA_OBJETCS = testprintfileoperation.obj EXTRA_LIBS = $(PANGOCAIRO_LIBS) diff --git a/tests/testoffscreen.c b/tests/testoffscreen.c deleted file mode 100644 index 113376b49f..0000000000 --- a/tests/testoffscreen.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - * testoffscreen.c - */ - -#include -#include -#include -#include "gtkoffscreenbox.h" - - -static void -combo_changed_cb (GtkWidget *combo, - gpointer data) -{ - GtkWidget *label = GTK_WIDGET (data); - gint active; - - active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); - - gtk_label_set_ellipsize (GTK_LABEL (label), (PangoEllipsizeMode)active); -} - -static gboolean -layout_draw_handler (GtkWidget *widget, - cairo_t *cr) -{ - GtkLayout *layout = GTK_LAYOUT (widget); - GdkWindow *bin_window = gtk_layout_get_bin_window (layout); - GdkRectangle clip; - - gint i, j, x, y; - gint imin, imax, jmin, jmax; - - if (!gtk_cairo_should_draw_window (cr, bin_window)) - return FALSE; - - gdk_window_get_position (bin_window, &x, &y); - cairo_translate (cr, x, y); - - gdk_cairo_get_clip_rectangle (cr, &clip); - - imin = (clip.x) / 10; - imax = (clip.x + clip.width + 9) / 10; - - jmin = (clip.y) / 10; - jmax = (clip.y + clip.height + 9) / 10; - - for (i = imin; i < imax; i++) - for (j = jmin; j < jmax; j++) - if ((i + j) % 2) - cairo_rectangle (cr, - 10 * i, 10 * j, - 1 + i % 10, 1 + j % 10); - - cairo_fill (cr); - - return FALSE; -} - -static gboolean -scroll_layout (gpointer data) -{ - GtkWidget *layout = data; - GtkAdjustment *adj; - - adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout)); - gtk_adjustment_set_value (adj, gtk_adjustment_get_value (adj) + 5.0); - return G_SOURCE_CONTINUE; -} - -static guint layout_timeout; - -static void -create_layout (GtkWidget *vbox) -{ - GtkAdjustment *hadjustment, *vadjustment; - GtkLayout *layout; - GtkWidget *layout_widget; - GtkWidget *scrolledwindow; - GtkWidget *button; - gchar buf[16]; - gint i, j; - - scrolledwindow = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_SHADOW_IN); - gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_CORNER_TOP_RIGHT); - - gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE); - - layout_widget = gtk_layout_new (NULL, NULL); - layout = GTK_LAYOUT (layout_widget); - gtk_container_add (GTK_CONTAINER (scrolledwindow), layout_widget); - - /* We set step sizes here since GtkLayout does not set - * them itself. - */ - hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout)); - vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (layout)); - gtk_adjustment_set_step_increment (hadjustment, 10.0); - gtk_adjustment_set_step_increment (vadjustment, 10.0); - gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (layout), hadjustment); - gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (layout), vadjustment); - - gtk_widget_set_events (layout_widget, GDK_EXPOSURE_MASK); - g_signal_connect (layout, "draw", - G_CALLBACK (layout_draw_handler), - NULL); - - gtk_layout_set_size (layout, 1600, 128000); - - for (i = 0 ; i < 16 ; i++) - for (j = 0 ; j < 16 ; j++) - { - g_snprintf (buf, sizeof (buf), "Button %d, %d", i, j); - - if ((i + j) % 2) - button = gtk_button_new_with_label (buf); - else - button = gtk_label_new (buf); - - gtk_layout_put (layout, button, j * 100, i * 100); - } - - for (i = 16; i < 1280; i++) - { - g_snprintf (buf, sizeof (buf), "Button %d, %d", i, 0); - - if (i % 2) - button = gtk_button_new_with_label (buf); - else - button = gtk_label_new (buf); - - gtk_layout_put (layout, button, 0, i * 100); - } - - layout_timeout = g_timeout_add (1000, scroll_layout, layout); -} - -static void -create_treeview (GtkWidget *vbox) -{ - GtkWidget *scrolledwindow; - GtkListStore *store; - GtkWidget *tree_view; - GtkIconTheme *icon_theme; - GList *icon_names; - GList *list; - - scrolledwindow = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_SHADOW_IN); - - gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE); - - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); - g_object_unref (store); - - gtk_container_add (GTK_CONTAINER (scrolledwindow), tree_view); - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1, - "Icon", - gtk_cell_renderer_pixbuf_new (), - "icon-name", 0, - NULL); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1, - "Label", - gtk_cell_renderer_text_new (), - "text", 1, - NULL); - - icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (vbox)); - icon_names = gtk_icon_theme_list_icons (icon_theme, NULL); - icon_names = g_list_sort (icon_names, (GCompareFunc) strcmp); - - for (list = icon_names; list; list = g_list_next (list)) - { - const gchar *name = list->data; - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, name, - 1, name, - -1); - } - - g_list_free_full (icon_names, g_free); -} - -static GtkWidget * -create_widgets (void) -{ - GtkWidget *main_hbox, *main_vbox; - GtkWidget *vbox, *hbox, *label, *combo, *entry, *button, *cb; - GtkWidget *sw, *text_view; - - main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - - main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE); - - label = gtk_label_new ("This label may be ellipsized\nto make it fit."); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE); - - combo = gtk_combo_box_text_new (); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "NONE"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "START"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "MIDDLE"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "END"); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); - gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE); - - g_signal_connect (combo, "changed", - G_CALLBACK (combo_changed_cb), - label); - - entry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (entry), "an entry - lots of text.... lots of text.... lots of text.... lots of text.... "); - gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE); - - label = gtk_label_new ("Label after entry."); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE); - - button = gtk_button_new_with_label ("Button"); - gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE); - - button = gtk_check_button_new_with_mnemonic ("_Check button"); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE); - - cb = gtk_combo_box_text_new (); - entry = gtk_entry_new (); - gtk_widget_show (entry); - gtk_container_add (GTK_CONTAINER (cb), entry); - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item0"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item1"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item1"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item2"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item2"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (cb), "item2"); - gtk_entry_set_text (GTK_ENTRY (entry), "hello world ♥ foo"); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); - gtk_box_pack_start (GTK_BOX (vbox), cb, TRUE, TRUE); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - text_view = gtk_text_view_new (); - gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE); - gtk_container_add (GTK_CONTAINER (sw), text_view); - - create_layout (vbox); - - create_treeview (main_hbox); - - return main_vbox; -} - - -static void -scale_changed (GtkRange *range, - GtkOffscreenBox *offscreen_box) -{ - gtk_offscreen_box_set_angle (offscreen_box, gtk_range_get_value (range)); -} - -static GtkWidget *scale = NULL; - -static void -remove_clicked (GtkButton *button, - GtkWidget *widget) -{ - gtk_widget_destroy (widget); - g_source_remove (layout_timeout); - - gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); - gtk_widget_set_sensitive (scale, FALSE); -} - -int -main (int argc, - char *argv[]) -{ - GtkWidget *window, *widget, *vbox, *button; - GtkWidget *offscreen = NULL; - gboolean use_offscreen; - - gtk_init (&argc, &argv); - - use_offscreen = argc == 1; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 300,300); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - - scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, - 0, G_PI * 2, 0.01); - gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE); - - button = gtk_button_new_with_label ("Remove child 2"); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE); - - if (use_offscreen) - { - offscreen = gtk_offscreen_box_new (); - - g_signal_connect (scale, "value_changed", - G_CALLBACK (scale_changed), - offscreen); - } - else - { - offscreen = gtk_paned_new (GTK_ORIENTATION_VERTICAL); - } - - gtk_box_pack_start (GTK_BOX (vbox), offscreen, TRUE, TRUE); - - widget = create_widgets (); - if (use_offscreen) - gtk_offscreen_box_add1 (GTK_OFFSCREEN_BOX (offscreen), - widget); - else - gtk_paned_add1 (GTK_PANED (offscreen), widget); - - widget = create_widgets (); - if (1) - { - GtkWidget *widget2, *box2, *offscreen2; - - offscreen2 = gtk_offscreen_box_new (); - gtk_box_pack_start (GTK_BOX (widget), offscreen2, FALSE, FALSE); - - g_signal_connect (scale, "value_changed", - G_CALLBACK (scale_changed), - offscreen2); - - box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_offscreen_box_add2 (GTK_OFFSCREEN_BOX (offscreen2), box2); - - widget2 = gtk_button_new_with_label ("Offscreen in offscreen"); - gtk_box_pack_start (GTK_BOX (box2), widget2, FALSE, FALSE); - - widget2 = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (widget2), "Offscreen in offscreen"); - gtk_box_pack_start (GTK_BOX (box2), widget2, FALSE, FALSE); - } - - if (use_offscreen) - gtk_offscreen_box_add2 (GTK_OFFSCREEN_BOX (offscreen), widget); - else - gtk_paned_add2 (GTK_PANED (offscreen), widget); - - gtk_widget_show_all (window); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (remove_clicked), - widget); - - gtk_main (); - - return 0; -} diff --git a/tests/testoffscreenwindow.c b/tests/testoffscreenwindow.c deleted file mode 100644 index c3b064c578..0000000000 --- a/tests/testoffscreenwindow.c +++ /dev/null @@ -1,87 +0,0 @@ -#include - -static gboolean -da_draw (GtkWidget *widget, - cairo_t *cr, - gpointer user_data) -{ - GtkOffscreenWindow *offscreen = (GtkOffscreenWindow *)user_data; - - cairo_set_source_surface (cr, - gtk_offscreen_window_get_surface (offscreen), - 50, 50); - cairo_paint (cr); - - return FALSE; -} - -static gboolean -offscreen_damage (GtkWidget *widget, - GdkEventExpose *event, - GtkWidget *da) -{ - gtk_widget_queue_draw (da); - - return TRUE; -} - -static gboolean -da_button_press (GtkWidget *area, GdkEventButton *event, GtkWidget *button) -{ - gtk_widget_set_size_request (button, 150, 60); - return TRUE; -} - -int -main (int argc, char **argv) -{ - GtkWidget *window; - GtkWidget *button; - GtkWidget *offscreen; - GtkWidget *da; - - gtk_init (&argc, &argv); - - offscreen = gtk_offscreen_window_new (); - - button = gtk_button_new_with_label ("Test"); - gtk_widget_set_size_request (button, 50, 50); - gtk_container_add (GTK_CONTAINER (offscreen), button); - gtk_widget_show (button); - - gtk_widget_show (offscreen); - - /* Queue exposures and ensure they are handled so - * that the result is uptodate for the first - * expose of the window. If you want to get further - * changes, also track damage on the offscreen - * as done above. - */ - gtk_widget_queue_draw (offscreen); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (window, "delete-event", - G_CALLBACK (gtk_main_quit), window); - da = gtk_drawing_area_new (); - gtk_container_add (GTK_CONTAINER (window), da); - - g_signal_connect (da, - "draw", - G_CALLBACK (da_draw), - offscreen); - - g_signal_connect (offscreen, - "damage-event", - G_CALLBACK (offscreen_damage), - da); - - gtk_widget_add_events (da, GDK_BUTTON_PRESS_MASK); - g_signal_connect (da, "button_press_event", G_CALLBACK (da_button_press), - button); - - gtk_widget_show_all (window); - - gtk_main(); - - return 0; -} diff --git a/testsuite/gtk/notify.c b/testsuite/gtk/notify.c index c5dbd23d3c..65aba315b8 100644 --- a/testsuite/gtk/notify.c +++ b/testsuite/gtk/notify.c @@ -503,10 +503,6 @@ test_type (gconstpointer data) if (type == GTK_TYPE_COLOR_BUTTON && pspec->owner_type == GTK_TYPE_BUTTON) continue; - /* GdkOffscreenWindow is missing many implementations */ - if (type == GTK_TYPE_OFFSCREEN_WINDOW) - continue; - /* Too many special cases involving -set properties */ if (g_str_equal (g_type_name (pspec->owner_type), "GtkCellRendererText") || g_str_equal (g_type_name (pspec->owner_type), "GtkTextTag")) diff --git a/testsuite/gtk/treeview.c b/testsuite/gtk/treeview.c index b439dc3fe0..9488cd7c13 100644 --- a/testsuite/gtk/treeview.c +++ b/testsuite/gtk/treeview.c @@ -192,7 +192,7 @@ test_row_separator_height (void) gtk_list_store_insert_with_values (store, &iter, 3, 0, "Row content", -1); gtk_list_store_insert_with_values (store, &iter, 4, 0, "Row content", -1); - window = gtk_offscreen_window_new (); + window = gtk_invisible_new (); tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (tree_view), diff --git a/testsuite/reftests/label-sizing.ref.ui b/testsuite/reftests/label-sizing.ref.ui index 3289e15569..5baf8f2914 100644 --- a/testsuite/reftests/label-sizing.ref.ui +++ b/testsuite/reftests/label-sizing.ref.ui @@ -1,7 +1,7 @@ - + False popup diff --git a/testsuite/reftests/label-sizing.ui b/testsuite/reftests/label-sizing.ui index 83b28627b8..2a1c839ab7 100644 --- a/testsuite/reftests/label-sizing.ui +++ b/testsuite/reftests/label-sizing.ui @@ -1,7 +1,7 @@ - + False popup -- 2.30.2